0%

The difference between && and &, | and ||, > and >> in Linux

& and && ๐ŸŒŸ

& means to execute the task in the background, if you want to run redis-server in the background:

1
redis-server &

&& means that the condition for executing the next command is that the previous command was executed successfully, such as:

1
echo '1' && echo '2'

| and || ๐Ÿ”…

| means the output of the previous command as the next command parameter, such as:

1
echo 'yes' | wc -l

|| means that the condition for executing the next command is that the previous command failed to execute, such as:

1
cat nofile || echo "fail"

> and >> ๐Ÿ’ฅ

> means a redirect, deleting the original content and then writing the new content, such as:

1
echo '1' > xx.txt

>> also means redirection, appending new content to the original content, such as:

1
echo '2' >> xx.txt