Linked Questions

226 votes
3 answers

What's the difference between semicolon and double ampersand && [duplicate]

What is the difference between echo "Hello " ; echo "world" and echo "Hello " && echo "world" Both seems to run the two commands after each other.
  • 3,956
138 votes
4 answers

What is the difference between "&&" and ";" when chaining commands [duplicate]

What is the difference between the following methods of chaining commands? cmd1; cmd2 cmd1 && cmd2
  • 2,286
46 votes
5 answers

Is there a difference between `;` and `&&` and `|`? [duplicate]

When you want to run multiple commands you can use ;, && and | Like this: killall Finder; killall SystemUIServer, cd ~/Desktop/ && rm Caches Or: man grep | man cat for example. But, ...
  • 11.2k
43 votes
3 answers

What does ">" do vs ">>"? [duplicate]

I am currently doing preparation for my GCSE computing controlled assessment on Linux. I type ls > list and ls >> list into the command line, but it does not do anything. I have googled it ...
  • 761
31 votes
3 answers

What does || mean in bash? [duplicate]

Apologies if this is a duplicate post. I did try searching to see if someone already asked/answered this but didn't find anything. What does || mean in bash? For example, in researching steps to ...
  • 8,649
45 votes
2 answers

Difference between executing multiple commands with && and ; [duplicate]

What's the difference between executing multiple commands with && and ;? Examples: echo "Hi\!" && echo "How are you?" and echo "Hi\!"; echo "How are you?"
32 votes
2 answers

How do I run a command only after previous command is unsuccessful in bash? [duplicate]

We use && operator to run a command after previous one finishes. update-system-configuration && restart-service but how do I run a command only if previous command is unsuccessful ? ...
39 votes
2 answers

What is &>> in a shell script [duplicate]

In a script I have inherited the output of one of our programs is put in to a file with: program &>> result.txt I have been reading in my book "Learning the bash shell" at home over the ...
  • 391
38 votes
2 answers

What does the < (left chevron / triangle bracket) do? [duplicate]

I understand that the > (right chevron) is for redirecting the STDOUT of a program to a file, as in echo 'polo' > marco.txt will create a text file called marco.txt with polo as the contents ...
  • 576
33 votes
1 answer

Difference between parentheses and braces in terminal? [duplicate]

( du /etc; du /var; ) > tmp.txt { du /etc; du /var; } > tmp.txt Is there a difference between the () and {}? The output of tmp.txt seems exactly the same, and I was wondering whether i'm ...
  • 441
11 votes
2 answers

How to redirect the output of a command to an already existing file without deleting its contents? [duplicate]

I am making a backup of some files and am creating a checksum file, checksums.txt, to later check the integrity of my data. However pasting each checksum manually into the file is inconvenient since ...
  • 1,039
15 votes
1 answer

POSIX compliant way to redirect stdout and stderr to a file [duplicate]

I am trying to write a script which is POSIX compliant, so it can run on any *nix system (Debian, Fedora, CentOS, AIX, Arch... ALL of them). When it comes to redirection, I am rather confused on what ...
8 votes
1 answer

what is the difference between >&2 and &>2 [duplicate]

Just wondering if there is any difference between: echo "running the npm patch" >&2; and echo "running the npm patch" &>2; I have actually never really understand that syntax.
6 votes
2 answers

What is the difference between > and >> (especially as it relates to use with the cat program)? [duplicate]

Suppose that I have a file called temp.txt. Using the cat program, I would like to add the contents of this file to the end of myfile.txt -- creating myfile.txt if it does not exist and appending to ...
  • 15.8k
0 votes
1 answer

How do I use: cat << EOF [duplicate]

I am little confused and not sure, how to add the cat << EOF style to my script. Would really appreciate a little feedback and help. Here is my script !/bin/sh #This is a disk mailer script ...

15 30 50 per page
2 3 4 5