I would like to grep the word “s a i” (which has spaces in it) in a xyz.txt
file which is saved in another directory. I tried to find an answer but I didn’t manage to find any. I have to use the grep
command only.
Asked
Active
Viewed 4.1k times
4

Ronan Boiteau
- 9,608
- 6
- 34
- 56

Sai Srikanth
- 41
- 1
- 1
- 4
-
There is zero problems grepping with spaces. There is a possible problem passing an argument with spaces in shell. Until you provide an examples and errors you encounter, it is hard to tell what answer should look like. – myaut Nov 22 '17 at 06:52
-
Just in case it helps the next person - I was searching for two words as well and found that the second word was not capitalized as I'd expected. Something else to double check if you've landed here like me. – DJ Quimby May 25 '21 at 21:12
3 Answers
4
Just add quotes around your grep
command:
grep "s a i" "another directory/xyz.txt"

Ronan Boiteau
- 9,608
- 6
- 34
- 56