linux sed 命令
发布时间:2020-12-13 14:08:24 所属栏目:Linux 来源:网络整理
导读:aabbcc Hello world! Hello Jack!Hello China!Hello Nick! $ test.txt # 删除第二行到最后一行 选项 -i $ -i '1d' test.txt $ test.txt # 在第一行下面新增一行,内容为 test.txt # 在最后一行下面新增一行,内容为 , test.txt # 一次增加多行需要使用换行符
aa
bb
cc
Hello world! Hello Jack!
Hello China!
Hello Nick!
$ test.txt # 删除第二行到最后一行
选项 -i
$ -i '1d' test.txt
$ test.txt # 在第一行下面新增一行,内容为 test.txt # 在最后一行下面新增一行,内容为 , test.txt # 一次增加多行需要使用换行符 n
$ -e '1a xxx' -e '2a yyy' test.txt
1i Hello world!
2i Hello world!
3i Hello world!
$ -f commands test.txt
$ test.txt # 把第一行替换为 test.txt # 把第一行到第三行替换为
$ hello.txt # 把Hello 替换为 Hi
$ hello.txt # 把匹配到的所有Hello 都替换为 Hi
$ hello.txt # 只在第二行和第三行进行替换操作
$ hello.txt # 删除字符串 Hello
$ -n test.txt 和命令sed -n hello.txt
$ -n -n -n -n test.txt # 匹配第三行和第三行后的每一行
$ -n hello.txt
$ -n hello.txt
$ hello.txt # 找到匹配的行,在这些行中执行替换
$ -i -i my.cnf
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |