我需要通过shell脚本来注释一个模式匹配的文件
我有一个文件,里面有一些数据,比如:
hello123
123hello
hello1
11hello
hello11
hello122
我需要评论一条精确匹配的图案线。
例如,我需要从给定的文件中注释"hello1“,然后文件内容必须如下
hello123
123hello
# hello1
11hello
hello11
hello122
避免另一行注释,与正常模式匹配。
发布于 2015-11-27 06:55:36
你可以用sed..。
sed 's/^hello1$/# &/' file
或
sed '/^hello1$/s/^/# /' file
https://stackoverflow.com/questions/33951751
复制相似问题