从文件中删除所有以 # 开头的行 [英] Delete all lines beginning with a # from a file
本文介绍了从文件中删除所有以 # 开头的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
文件中所有带有注释的行都以 #
开头.如何删除以 #
开头的所有行(仅那些行)?其他包含 #
但不在行首的行应该被忽略.
All of the lines with comments in a file begin with #
. How can I delete all of the lines (and only those lines) which begin with #
? Other lines containing #
, but not at the beginning of the line should be ignored.
推荐答案
这可以通过 sed 单行:
sed '/^#/d'
这表示,找到所有以 # 开头的行并删除它们,留下所有其他内容."
This says, "find all lines that start with # and delete them, leaving everything else."
这篇关于从文件中删除所有以 # 开头的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文