grep -w只有空格作为分隔符 [英] grep -w with only space as delimiter
本文介绍了grep -w只有空格作为分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
grep -w uses punctuations and whitespaces as delimiters.
如何将grep设置为仅使用空格作为分隔符?
How can I set grep to only use whitespaces as a delimiter for a word?
推荐答案
c>与 grepfoo
相同。如果您还想匹配行尾或制表符,您可以开始执行如下操作: grep'\(^ \ | \)foo\($ \ | \)'
,但你最好用 perl -ne'print if / \sfoo\s /'
If you want to match just spaces: grep -w foo
is the same as grep " 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 with perl -ne 'print if /\sfoo\s/'
这篇关于grep -w只有空格作为分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文