Reputation: 58
I have a ksh file where I have following lines of code
find . \
\( \
-name \*.tar -o \
-name \*.gz -o \
-name log.\* -o \
-name out.\* \
\) \
I am interested in knowing the purpose of these backslashes . Is it for escaping something ?
Upvotes: 1
Views: 2586
Reputation: 941
Backslashes have two purposes here:
At the end of the line: Let the shell ignore the newline i.e. the command goes on in the next line. Without it the shell would think that a new command starts in the next line.
Within a line: Escape the next character, so that the shell does not parse it. These characters usually have special meanings to the shell. The backslash removes this meaning so that the character is passed to find
"as is".
Read more about this here: Which characters need to be escaped when using Bash?. It's about Bash but KSH is similar.
Upvotes: 1
Reputation: 1383
Rewritten in one line:
find . \( -name "*.tar" -o -name "*.gz" -o -name "log.*" -o -name "out.*" \)
Btw. last -o (must be followed by option) and backslash are wrong in Your example
Upvotes: 1