How will you search for the character '\' in a file ?
-
grep '\' filename
-
grep \\ filename
-
grep '\\' filename
-
grep "\" filename
A,B,D
Correct answer
Explanation
To search for a literal backslash character with grep, you need proper escaping. Single quotes (A) need 4 backslashes, single quotes with escape (B) need 8 backslashes due to shell processing, and double quotes (D) need 3 backslashes. Option C with 6 backslashes is incorrect.