我正在尝试使用 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