The backslash only masks the next character and can be typed faster if you just want to mask it, but it can depend on the keyboard layout and whether you enter 10 fingers blindly or not. I prefer quotes because they are easier to enter.
Disguising each other in and of itself is another difference:
echo \\
prints backslash but
echo "\"
will display the symbol "and wait for the quote to close.
echo \"
will work and output a quote but
echo """
for the same reason as above, will not.
Some special characters, such as linefeed, formfeed, tab, alert, etc., can only be created with backslashes, but not with quotes, including backslashes.
/bin/echo -e "\tfoo\abar\bbar\ffoo\nbar\rfoo"
See man echo for a complete list.
This is not only true for echo , but also for many things you can do in scripts that work with strings.
source share