我目前可以使用 sed 进行替换,如下所示:
sed -i 's/find/replace/g' /file
是否可以找到http {
等内容并在 sed 之后插入以下内容?
\t/server_names_hash_bucket_size 64;
(内容前的标签)?
答案 0 :(得分:1)
是的,可以使用\a
:
$ sed '/^http {/ a\\tserver_names_hash_bucket_size 64;' file
它会查找以http {
开头的行(^
代表行的开头)并添加(\a
)您指定的文字。