2. Sed 语法初步

12 篇文章 0 订阅
sed [-n] [-e] 'command(s)' files 
sed [-n] -f scriptfile files

可以写在 文件中使用 sed -f scriptfile files 这样的格式调用

在scriptfile中最后一个命令 写一行 类似于执行 sed -e 'commad1' -e 'commad2' files 或者 sed 'commad1;commad2' files

这一接使用到的选项有

选项意义
-nDefault printing of pattern buffer 默认情况下会在每行将pattern buffer 的内容打印出来 这个选项抑制打印
-f执行文件
-eexecute执行多个命令

GNU的选项

选项意思
-n, –quiet, –silent:Same as standard -n option.
-e script, –expression=script:Same as standard -e option.
-f script-file, –file=script-file:Same as standard -f option.
–follow-symlinks:If this option is provided, the SED follows symbolic links while editing files in place. 跟随链接到具体文件
-i[SUFFIX], –in-place[=SUFFIX]:This option is used to edit file in place. If suffix is provided, it takes a backup of the original file, otherwise it overwrites the original file. 这个用来编辑文件 用法 sed -i 'back' 'commad1;command2' files 这个命令的意思是将 files 进行修改 并且 修改之前 会创建一个.back 的备份文件
-l N, –line-lenght=N:This option sets the line length for l command to N characters. 规定每行长度是 N
–posix:This option disables all GNU extensions. 去除掉所有的GNU extensions
-r, –regexp-extended:This option allows to use extended regular expressions rather than basic regular expressions.加强版正则 有的时候会是-E
-u, –unbuffered:When this option is provided, the SED loads minimal amount of data from the input files and flushes the output buffers more often. It is useful for editing the output of “tail -f” when you do not want to wait for the output.
-z, –null-data:By default, the SED separates each line by a new-line character. If NULL-data option is provided, it separates the lines by NULL characters. 使用null 字符 区分行
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值