我有文本文件,我想要删除该行以 * 开头
我尝试使用 grep,它不起作用。
grep -v '^#'
建议表示赞赏。
\n
OG0018658
M0~bbe9a2ca8a9915aafa220a87c248a064 | M1~439516e2a637051372399975c71af47b | 0.009414**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M5~d51f0107310c1d9a8cbe5b0305c46986 | 0.009341**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M6~462cfd85f3d26c451e0ea388b1ee265e | 0.009341**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M7~f3c7a863e871762d7674e5a6f6aa1b0d | 0.009438**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M8a~17a2f94c77ce46d91db4dc8a50d30fd7 | 0.034070*
* Average omega for all tree: 0.167
* Average omega for all tree: 0.179
* Sites significantly caracterized
* Average omega for all tree: 0.179
* Sites significantly caracterized
* Average omega for all tree: 0.176
* Sites significantly caracterized
* Average omega for all tree: nan
* Average omega for all tree: 0.175
* Average omega for all tree: 0.175
* Average omega for all tree: 0.174
* Average omega for all tree: 0.174
* Average omega for all tree: 0.177
* Average omega for all tree: 0.167
* Average omega for all tree: 0.179
* Average omega for all tree: 0.179
* Average omega for all tree: 0.176
* Average omega for all tree: nan
* Average omega for all tree: 0.175
* Average omega for all tree: 0.175
* Average omega for all tree: 0.174
* Average omega for all tree: 0.174
* Average omega for all tree: 0.177
Modified file
\n
OG0018658
M0~bbe9a2ca8a9915aafa220a87c248a064 | M1~439516e2a637051372399975c71af47b | 0.009414**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M5~d51f0107310c1d9a8cbe5b0305c46986 | 0.009341**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M6~462cfd85f3d26c451e0ea388b1ee265e | 0.009341**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M7~f3c7a863e871762d7674e5a6f6aa1b0d | 0.009438**
M0~bbe9a2ca8a9915aafa220a87c248a064 | M8a~17a2f94c77ce46d91db4dc8a50d30fd7 | 0.034070*
答案1
简单的 awk 解决方案:
awk '$1!="*"' infile
等效的 sed 解决方案:
sed '/^[[:blank:]]*\*/d' infile
与 grep 中使用的正则表达式相同:
grep -v '^[[:blank:]]*\*' infile
答案2
但它们实际上以一些空白字符开头。
grep -v '^[[:blank:]]*\*' file.txt