Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

-1
votes
2answers
63 views

Value of variable set in 'while read' loop looses value outside the loop

The following code is a simplified version of the real life task. Of course I know that I could achieve what is done in this simplified example with a if [ ... ]. This is only to demonstrate the ...
3
votes
1answer
3k views

Two parts: linux startup script to connect to bluetooth and cron to keep it connected

I have a mini bluetooth keyboard and a Raspberry Pi running a Debian-based distro. I know the MAC address of the keyboard but for this question, let's just use AA:BB:CC:DD:EE:FF. Right now I have to ...
33
votes
5answers
10k views

Is there a shortcut to mkdir foo and immediately cd into it?

This is something I do frequently $ mkdir foo $ cd foo This works as a single command, but it's more keystrokes and saves no time. $ mkdir foo && cd foo Is there a shortcut for this? ...
0
votes
1answer
28 views

Start two scripts that run indefinitely in shell script

I'm a webdev and I am using JSX compiler and SASS preprocessor to compile my .jsx and .scss files. When I start working, I launch these two separate commands: jsx -x jsx jsx js --watch --no-cache-dir ...
-1
votes
2answers
50 views

simple loop not working

A simple script now="$(date +'%d_%m_%Y')" path="/var/www/vitalii/backups" sites=("site1.ru site2.ru site3.ru") for i in ${sites[*]} do echo "$path/$i" #tar -cvzf $path/$i_${now}.tgz ...
5
votes
2answers
2k views

Removing files matching a numeric range regular expression

I have a folder which has many files. Some of the data files are labelled 1, 2, 3, ..., 300 I want to remove these data files using the terminal. How do I do this? I want to do something like rm ...
1
vote
1answer
16 views

How do I remove files from a range in a folder? [duplicate]

How do I delete a specific frame range in a folder? I have star_bg_true.0001.dpx star_bg_true.0002.dpx .... star_bg_true.0100.dpx How do I remove only frames 0030–0050?
5
votes
1answer
3k views

Bash Find Files with zero size and delete files with different extensions

This command will find files of zero size: find . -size 0 A filename returned might be filename.001 I am looking for a one liner that will delete files found with this, plus any that have the ...
0
votes
0answers
59 views

ffmpeg through shell script is not running

I have to run a ffmpeg command . I am running the below command in command prompt and works fine. ffmpeg -v verbose -i rtsp://99.192.203.99:8091/test.sdp -i rtsp://99.192.203.99:8091/test.sdp ...
0
votes
1answer
46 views

shell standard streams redirection order OR 2>&1 1>/dev/null vs 1>/dev/null 2>&1

Can somebody please clarify differences? Is some of those considered as best practice? If I remember correct I somehow on SO read that this 1>/dev/null should precede this: 2>&1 ls -al ...
2
votes
9answers
1k views

Command to search programs in Linux

Do you have any easy idea to define some alias in .bashrc for finding some command that you want to search (when you forgot its name) in your machine, visiting all "bin" directories, maybe using ...
3
votes
1answer
137 views

Is there a way to get the path of a bash script when used in the source command

I want to set an environment variable relative to the location of a script. I can easily find and set it for the duration of the script (test.sh): #!/bin/bash export MY_VARIABLE=$(dirname $0) echo ...
4
votes
4answers
4k views

How to use Cmd's tab autocomplete effectively?

I've used the Bash shell on Linux for years and I'm very fast with it. By frequently appealing for autocomplete by hitting the tab key, I'm able to write long commands in few keystrokes. Recently at ...
5
votes
3answers
6k views

How to download this webpage with Wget?

I want to download the webpage http://forum.ubuntu-it.org/, but it requires a username and password. So I have used this: wget --save-cookies cookies.txt --post-data ...
1
vote
4answers
8k views

How to kill all the processes that have dates older than today?

I issue the command ps -aux | grep tony. It displays the following output tony 10986 0.0 0.0 33532 464 ? S Feb01 0:00 vncconfig -iconic tony 10988 0.0 0.0 86012 512 ? ...
6
votes
5answers
3k views

bash: execute command given in commandline and don't exit

how do I specifiy a command on the commmandline of bash which shall be executed once inside the new bash after reading ~/.bashrc -- But all this without letting bash exit after the command is ...
3
votes
1answer
42 views

how to control users login on Linux machine according to configuration file

I use the PAM to authenticate users login info from - http://linux.die.net/man/8/pam_listfile in my Linux red-hat machine I have 5 diff users user1 user2 user3 user4 user5 I want to enable ssh ...
19
votes
5answers
62k views

How can I get the mount path of a USB device on OSX?

I have a backup script that backs up some data to a USB device. The problem I have is that OSX sometimes changes the expected mount path. For example if some file is locked under the expected mount ...
6
votes
6answers
24k views

Creating and formating a partition using a bash script

Is there any way to create and format a partition using a bash script? I think it can be done with fdisk but I don't know how to feed commands from the bash script into the fdisk shell then exit the ...
2
votes
1answer
3k views

How to split the HTTP error code from the contents in cURL?

Yes, this is related to Getting curl to output HTTP status code? but unfortunately not the same. In a script I would like to run: curl -qSfsw %{http_code} URL where the -f option ensures that the ...
0
votes
2answers
102 views

How to run a script after startup on Ubuntu 14.04?

I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question. I have a rails application that I run with mongrel_rails start -e production -p 80. That ...
1
vote
3answers
36 views

How to move in a big jump on the bash shell?

Ctrl + A and Ctrl + E bring you to the beginning and end of the command line. How do you jump to the middle? or at least 20 chars or so? If any of you use bash a lot and type quickly, you end up ...
1
vote
1answer
46 views

Piping lines to repeat commands

If my grep operation returns a list of IDs like in the following, can I somehow feed/pipe each line to a commandline command's parameter?: 12345 84758 49549 .. Like for example with the above ...
1
vote
0answers
60 views

bash- command does not work with php shell_exec

I want to execute following command on my Ubuntu server using php: android create project --target 8 --name $fname --path ./$fname --activity MainActivity --package $fpack 2>&1 The above ...
0
votes
0answers
17 views

Starting a chroot and drop into nonprivileged user home

I need to (temporarily) jail a non-privileged user. I tried something like: sudo chroot --userspec=mcon:users /wherever/chroottarget /bin/bash -i This almost works, but it doesn't set env vars ...
1
vote
3answers
49 views

sudo command won't run from script

Linux Mint. Ok, this is going to be seriously basic but for some reason, I am mis-understanding how this works. If I type the following commands, everything works fine: cd ...
1
vote
1answer
34 views

Alias one program in a different order than $PATH

I alias pandoc='~/.cabal/bin/pandoc' because I don't want to change my $PATH order just for this one program. In general, programs I installed in /opt/, ~/.cabal/, and so on should precede defaults ...
0
votes
5answers
55 views

No such file or directory after typing $PATH in terminal

when I write in terminal echo $PATH my output is :/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin but when I write just : $PATH this output I do not understand ...
2
votes
3answers
176 views

What is the difference between terminal and bash? [duplicate]

When I open Terminal Window in Mac OS X, I can type bash and hit enter and I will see: Last login: Fri Feb 20 14:30:56 on ttys000 Korays-MacBook-Pro:~ koraytugay$ bash bash-3.2$ I can for example ...
29
votes
6answers
17k views

How do I get ls --color=auto to work on Mac OS X?

I'm trying to move my bash configuration from Ubuntu to Mac OS X and it looks like ls is slightly different. For instance, it won't accept the --color option. How do I get this to work?
2
votes
0answers
44 views

What are the benefits of keeping Caps Lock on after swapping with CTRL? [closed]

I have swapped CTRL and Caps Lock (as it is easier for emacs/bash to have homerow access to the CTRL key). Most places I have read don't mention whether they just turn off Caps Lock (don't remap to ...
0
votes
0answers
21 views

How to pipe arguments into stdin?

I am trying to generate a private key using keytool command, but it asks me for many details like my key passphrase, my name and my organization details. I want to pass all the inputs in one command. ...
0
votes
1answer
32 views

How to stream audio and capture at the same time

I would like to save the mp3 that is being stream to the local file for archival purposes. I'm using the following line in my bash script to stream audio from a USB audio device to my icecast ...
1
vote
1answer
41 views

Terminal new window always shows -bash: Searching: command not found

When open terminal, it always shows -bash: Searching: command not found. It does not affect other functions, just each time, even though open a new terminal window, it still pops up at the top of the ...
2
votes
1answer
149 views

I have to manually start bash

I'm somewhat a Linux noob, so I'm sorry if this is a very basic question. I tried to look on superuser for other answers, but i'm not exactly sure what i'm looking for. So, here's my problem. When I ...
2
votes
2answers
35 views

/etc/profile not being sourced at login

I'm having a bit of an issue: Neither of my /etc/profile or /etc/environment are getting sourced at login! i.e: After boot, the global variables I've got set in /etc/profile (and /etc/profile.d/*.sh ...
11
votes
12answers
17k views

Monitoring a file until a string is found

I am using tail -f to monitor a log file that is being actively written to. When a certain string is written to the log file, I want to quit the monitoring, and continue with the rest of my script. ...
2
votes
1answer
375 views

Enabling Bold and Color with LPT parallel printer

I know how to echo text to my HP Deskjet 420 printer on lubuntu with bash: echo -e "line of text" > /dev/lp0 Is there a way to print text that is bold or in color? Should I echo some sort of ...
0
votes
2answers
73 views

bash sed/awk: replace string from a file searching in another file

i have a question about search and replacement on Debian. I have two files. One with: a:b c:d e:f and the other with: e c a` In the second file I want to replace a with b, c with d, e with f. ...
0
votes
0answers
46 views

Crossfading Video AND Audio with ffmpeg

This Super User answer crossfade between 2 videos using ffmpeg has got me so far, but now that I have tried many solutions and seen every SO link out there, it's time to ask you all for help. I am ...
2
votes
0answers
51 views

How to curl or wget live tennis scores from a Google search page [closed]

Google has some nice live tennis scores displayed on the search page. If I search for "Halep", for example, I get the tournament she's currently playing, together with all the result and live score. ...
0
votes
1answer
27 views

Escape string input to sed

I'm having some problems with replacing a string in a file using sed with a string that contains newlines. The following will fail completely. I assume I've got to escape the replace_with string, but ...
5
votes
6answers
3k views

GNU Screen won't inherit my PATH on 10.5.8

I use screen on a daily basis for my terminal needs and I'm quite happy with it. Recently, though, I made some updates to my bash configuration files and I noticed that I was setting various PATH ...
0
votes
2answers
95 views

How do I configure easy_install to use the right Python interpreter?

I am using mac OSX and have installed python 2.7.9 via this article, from /usr/bin if I run the command ls -l /usr/bin/python* in a bash terminal, I get lrwxr-xr-x 1 root wheel 67 Jan 24 02:12 ...
0
votes
1answer
31 views

How to cp multiple file extensions?

How do I cp multiple file extensions, like png, jpg and tif files? I tried: $cp ./*.(jpg|png|tif) ../output/ >bash: syntax error near unexpected token `(` $cp ./01_reliefs/*.\(jpg\|png\|tif\) ...
5
votes
7answers
2k views

What is the difference between “Shell” and “Terminal”? [duplicate]

I am fairly new to Ubuntu and I am loving it! But I don't quite understand the difference between the shell and the terminal. Can any one explain? Someone told me that a terminal is just a "tool" to ...
0
votes
1answer
11 views

how to keep bash from waiting for spawned windows gui program to close

New to bash. And new to bash on windows and git. When I run gitk in the git-bash shell created by msysgit, bash will effectively hang waiting for the spawned gitk to close... Whereas cmd launches ...
1
vote
2answers
43 views

Wrong results when comparing two numbers with bc (bash)

I’ve encountered an error, probably a bug in bc. I encountered it when trying to compare two numbers on a script in bash. It turns out that when I do: echo "1.1E-2<1.1E-1" | bc -l It returns 1 ...
2
votes
2answers
4k views

Recursive zgrep not working

I have a directory hierarchy that contains numerous .gz files. I want to be able to recursively grep them for the string "foo". From what I've read online the following should work: zgrep -R -H ...
1
vote
1answer
40 views

Can't run /bin/bash… sometimes?

I’m on a Google Compute Engine which is running Debian Wheezy 7.4. I’ve been noticing strange things recently. For example, I can do sudo bash. But then, from root, I can’t do sudo -u anotherUser ...