我想使用grep -v -e''从文件中排除注释(带有#的行作为第一个非空白字符)。 #可以出现在行的开头,也可以在遇到第一个#之前以任意组合形式出现多个空格和制表符的组合。正则表达式排除注释
假设文件NP4包含此:
# hash at the begining of the line
## two hashes at the begining of the line
#### four hashes at the begining of the line
# two white spaces then a hash
a good line
another good line starting with a few spaces
a good line starting with a combination of spaces and tabs
# two white spaces, two tabes and then a hash
## two tabs, two white spaces and then two hashes
# tab, ws, tab, ws, tab then hash
我试着用下面的命令,但我认为这将不起作用。我只能得到三行作为输出。
的grep -v -e '^ \ S *#* $' NP4