What's the best way to search for a string in a file?

前端 未结 5 2089
悲&欢浪女
悲&欢浪女 2020-12-13 09:07

The title speaks for itself really. I only want to know if it exists, not where it is. Is there a one liner to achieve this?

5条回答
  •  执念已碎
    2020-12-13 09:31

    grep for foo OR bar OR baz, stolen from ruby1line.txt.

    $  ruby -pe 'next unless $_ =~ /(foo|bar|baz)/' < file.txt
    

提交回复
热议问题