grep -w uses punctuations and whitespaces as delimiters.
How can I set grep to only use whitespaces as a delimiter for a word?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to match just spaces:
grep -w foois the same asgrep " foo ". If you also want to match line endings or tabs you can start doing things like:grep '\(^\| \)foo\($\| \)', but you’re probably better off withperl -ne 'print if /\sfoo\s/'