加入收藏 | 设为首页 | 会员中心 | 我要投稿 衡阳站长网 (https://www.0734zz.cn/)- 数据集成、设备管理、备份、数据加密、智能搜索!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux sed 命令

发布时间:2021-01-26 00:08:18 所属栏目: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 # 删除第二行到最后一行

linux sed 命令

选项 -i

$ -i '1d' test.txt

linux sed 命令

$ test.txt # 在第一行下面新增一行,内容为 test.txt # 在最后一行下面新增一行,内容为 , test.txt # 一次增加多行需要使用换行符 n

linux sed 命令

$ -e '1a xxx' -e '2a yyy' test.txt

linux sed 命令

1i Hello world! 2i Hello world! 3i Hello world!

$ -f commands test.txt

linux sed 命令

$ test.txt # 把第一行替换为 test.txt # 把第一行到第三行替换为

linux sed 命令

$ hello.txt # 把Hello 替换为 Hi

linux sed 命令

$ hello.txt # 把匹配到的所有Hello 都替换为 Hi

linux sed 命令

$ hello.txt # 只在第二行和第三行进行替换操作

$ hello.txt # 删除字符串 Hello

linux sed 命令

linux sed 命令

$ -n test.txt 和命令sed -n hello.txt

linux sed 命令

$ -n -n -n -n test.txt # 匹配第三行和第三行后的每一行

$ -n hello.txt

$ -n hello.txt

$ hello.txt # 找到匹配的行,在这些行中执行替换

$ -i -i my.cnf

(编辑:衡阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读