The Linux operators and separators commands
The semicolon is used to separate two or more commands on a single line. The commands are executed one after the other, regardless of whether the previous command succeeds or fails.
cd Documents; ls -l
The double ampersand is used to execute the second command only if the first command succeeds. If the first command fails, the second command is not executed.
Copy code cd Documents && ls -l
The double pipe is used to execute the second command only if the first command fails. If the first command succeeds, the second command is not executed.
cd Documents || ls -l
The ampersand is used to run a command in the background. The command is executed in the background and the shell prompt returns immediately, allowing you to continue using the command line.
sleep 10 &
The pipe is used to redirect the output of one command to another command. The output of the first command is sent to the input of the second command.
ls | grep filename
These operators are used to redirect the input or output of a command to a file. The < operator is used to redirect input from a file, the > operator is used to redirect output to a file (overwriting any existing content), and the >> operator is used to redirect output to a file (appending to any existing content).
command > output.txt