Linked Questions

192
votes
3answers
87k views

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.
127
votes
4answers
87k views

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
32
votes
5answers
25k views

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, ...
42
votes
2answers
27k views

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?"
25
votes
3answers
58k views

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 ...
30
votes
2answers
36k views

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 ...
18
votes
2answers
42k views

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 ? ...
32
votes
2answers
22k views

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 ...
14
votes
3answers
37k views

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 ...
11
votes
2answers
9k views

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 ...
23
votes
1answer
7k views

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 ...
12
votes
1answer
2k views

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 ...
6
votes
2answers
9k views

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 ...
5
votes
1answer
14k views

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.
0
votes
1answer
57k views

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
1
2 3 4 5
13