问题
How to perform a 'grep' search which doesn't display any lines that have the comment marks "//" in the front of the line, but also ignore whitespace in front of the "//" marks?
I attempted grep your_search_pattern' where_to_look | grep -v '^//
, but it does not ignore lines that have spaces before "//".
回答1:
grep 'your_search_pattern' where_to_look | grep -v '^//'
回答2:
You might check out the man page for grep
.
Some things pertaining to your question:
the
-v
switch will invert your search^
matches the beginning of the line.
You should be able to piece the rest together.
(edit: or look above.)
回答3:
Using awk you don't need to use multiple piped commands:
awk '/paatern/ && !/^\/\//' file
来源:https://stackoverflow.com/questions/19085802/how-to-perform-a-grep-search-that-excludes-line-starting-with-and-its-prec