The following bash permits of running the commands 1,2,3 in all the folders that has names included in the file "list.txt"   #!/bin/bash cat list.txt | while read i  do command1 &amp; command2 &amp; command3 &amp; done   The commands 1,2,3 in the code are running together in all the folders that has names included in the file "list.txt" . How can the commands run one by one in all the folders (i.e. when the first command finish the second command start and so on...). I tried to use "wait" between the commands but it didn't work! The solution suggested here  didn't work well! I am looking for another solution
121643
I have parent folder "parent". Inside this folder I have subfolders, and a file named "names.txt". this file includes the names of these subfolders as follow:  Parent_folder folder1 folder2 folder3 folder4 . . . . names.txt   The content of the file "names.txt" is as follow:  folder1 folder2 folder3 folder4 . . .   Inside every folder I have images and I want to apply consecutively 10 scripts on every image ( every script must finish it is job inside every folder, then the second script must be run). These scripts have different names and they are exist in one folder. I set an environment by sourcing a file then I can call these scripts by its name from terminal .At the same time I want to apply this process on all the folders at once. i.e. when script #1 is running, I want it to be running on all the folders at the same time. When it is done and script #2 will start. I want it to start in all the folders at once and so on... In order to achieve this I wrote the following code:  #!/bin/bash path=PATH/TO/THE/PARENT/FOLDER for i in $(cat $path/names.txt); do { script#1 } &amp; { script#2 } &amp; . . .  done   This code is not working efficiently as all the commands are running at once. I want the commands to run on all the folders at once but consecutively.  What I am doing wrong?
112657
I know I can solve this problem several ways, but I'm wondering if there is a way to do it using only bash built-ins, and if not, what is the most efficient way to do it.  I have a file with contents like  AAA B C DDD FOO BAR   by which I only mean it has several lines and each line may or may not have spaces.  I want to run a command like  cmd AAA "B C DDD" "FOO BAR"   If I use cmd $(&lt; file) I get  cmd AAA B C DDD FOO BAR   and if I use cmd "$(&lt; file)" I get  cmd "AAA B C DDD FOO BAR"   How do I get each line treated a exactly one parameter?
110327
I have separate scripts for tasks in bash. Here is the broken one:  #!/bin/bash PATH=/home/name/ mkdir $PATH cd $PATH &amp;&amp; echo "done." exit 0   Today it broke and first time it simply didn't want to run cd, but created directory. Second time it just said "mkdir command not found." Running this commands exactly with semicolon works fine. What the case?
67791
I have about a dozen Linux boxes that I occasionally need to run the same command(s) on. Is there an easier way (or automated way) to do this asides from logging on to each machine and running the command, one at a time? It's not the same commands all the time and it's not at a preset time so it's not something ideal for tools like cron.
100532
The runtime arguments are as follows: $1 is the path to the file containing the list of files $2 is the path to the directory containing the files What I want to do is check that each file listed in $1 exists in the $2 directory  I'm thinking something like:  for f in 'cat $1' do if (FILEEXISTSIN$2DIRECTORY) then echo '$f exists in $2' else echo '$f is missing in $2' sleep 5 exit fi done   As you can see, I want it so that if any of the files listed in $1 don't exist in the directory $2, the script states this then closes. The only part I can't get my head around is the (FILEEXISTSIN$2DIRECTORY) part. I know that you can do [ -e $f ] but I don't know how you can make sure its checking that it exists in the $2 directory.
34127
I have multiple files in multiple folders under one directory that need to be in one folder. Is there a command line that can help me accomplish this?
50840
I want to do such as following:  #!/bin/bash command1 pause 30 seconds command2 exit   This is only example script with pause of 30 seconds between run of 2 command.  How to do this?
109277
If I am correct, command substitution, process substitution, pipeline, and background jobs run the commands specified within themselves in a subshell not in the original shell.  But when the commands are jobs or dirs, they output exactly the same as when they are run directly in the original shell:  echo $( jobs )  cat &lt;(jobs)  jobs | less  echo $( dirs )  cat &lt;(dirs)  dirs | less  dirs &amp;   Why is that? Is it because the subshells inherit the jobs and dirs stack from the original shell, or because jobs and dirs are run in the original shell instead of the subshells?  But   jobs &amp;   doesn't output anything. Why is it different from the other commands? Thanks.  Related
22263
How can I repeat a command every interval of time , so that it will allow  me to run commands for checking  or monitoring  directories ?   There is no need for a script, i need just a simple command to be executed in terminal.
3477
I don't quite understand how the computer reads this command.  cat file1 file2 1&gt; file.txt 2&gt;&amp;1  If I understand, 2&gt;&amp;1 simply redirect Standard Error to Standard Output.  By that logic, the command reads to me as follows:    concatenate files file1 and file2.  send stdout from this operation to file.txt. send stderr to stdout. end?   I'm not sure what the computer's doing. By my logic, the command should be   cat file1 file2 2&gt;&amp;1 &gt; file.txt   but this is not correct.
11929
I often start a long running command that is bound to either CPU, Disk, RAM or Internet connection. While that is running, I find that I want to run a similar command. Let's say downloading something big.  Then I start a shell with wget ...1 and let it run. I could open another shell and run the other wget ...2, but now they would fight for the bandwidth. When I just type the second command into the running shell, it will execute that later on, since wget is not interactive.  Is there a reasonable way to do this with either Bash or Fish Shell?
48411
To create a playlist for all of the music in a folder, I am using the following command in bash:  ls &gt; list.txt   I would like to use the result of the pwd command for the name of the playlist.  Something like:  ls &gt; ${pwd}.txt   That doesn't work though - can anyone tell me what syntax I need to use to do something like this?  Edit: As mentioned in the comments pwd will end up giving an absolute path, so my playlist will end up being named .txt in some directory - d'oh! So I'll have to trim the path. Thanks for spotting that - I would probably have spent ages wondering where my files went!
50034
I've encountered a headache problem.  I want to execute mulitple commands in background, so I want to start them in bash one by one. It's easy to start one command in linux shell in background, just like this:  myCommand &amp;   It's also easy to start multiple commands, just like this:  myCommand1 &amp;&amp; myCommand2   or  myCommand1 ; myCommand2   But if I want to run multiple commands in background, I tried the following command format, but failed:  myCommand1 &amp; &amp;&amp; myCommand2 &amp;   or   myCommand1 &amp; ; myCommand2 &amp;   Both formats fail. How can I run multiple commands which have &amp; in one command line?
43301
I think it's something like  this: (Fedora14/bash)  #!/bin/bash  for i in {0..10..1}; do echo -e "$i"'\c' echo -e "\n\r" sleep 1 done   But it doesn't work. Purpose: like this, but without the "clear":   #!/bin/bash  for i in {0..10..1}; do echo -e "$i" sleep 1 clear done   So a counting script that doesn't deletes the whole screen to output +1 number, instead it only deletes the line, where the counting is, so that there could be ex.: a beatifull "progress bar"..
72552
How do I work recursively through a directory tree and execute a specific command on each file, and output the path, filename, extension, filesize and some other specific text to a single file in bash.
100185
I was looking at   and I wondered if the following could be done from terminal. I did it in python, just want to see if it could be done from terminal, bash scripting or whatever.  Suppose I have a file that looks like so:  2,4,5,14,9 40,3,5,10,1   could it be sorted like so, by rows (lines)  2,4,5,9,14 1,3,5,10,40   or is it too complicated? I did it using python, I just want to know if it could be done so next time I might not use python. What I have done, is creating lists and sorting them.
66160
I can run this command from my command line prompt:  cp -r folder/!(exclude-me) ./   To recursively copy all contents of folder except for the subdirectory named exclude-me into the current directory.  This works exactly as intended.  However, I need this to work in a bash script I've written, where I have this:  if [ -d "folder" ]; then   cp -r folder/!(exclude-me) ./   rm -rf folder fi   But when I run the script:  bash my-script.sh   I get this:  my-script.sh: line 30: syntax error near unexpected token `(' my-script.sh: line 30: `  cp -r folder/!(exclude-me) ./'   And I'm at a loss as to why it works from the command prompt, but the exact same line doesn't work in a bash script.