learn Linux sed command

一、参考文档:
. sed命令详解
http://qifuguang.me/2015/09/21/sed%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/
. linux之sed用法
http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html
. Sed 的man手册参数详细解释(一)
http://blog.csdn.net/imfinger/article/details/6071175 二、sed命令的使用规则是这样的:
sed [option] 'command' input_file 三、options:
-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
add the script to the commands to be executed
如果命令行上只有一个指令的时候可以不用写-e,但是如果有多个指令的话一定要在每个指令的前面加-e选项。
-f script-file, --file=script-file
add the contents of script-file to the commands to be executed
这里貌似是前面对应的-e对应的脚本
--follow-symlinks
follow symlinks when processing in place
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
-l N, --line-length=N
specify the desired line-wrap length for the `l' command
--posix
disable all GNU extensions.
-r, --regexp-extended
use extended regular expressions in the script.
-s, --separate
consider files as separate rather than as a single continuous
long stream.
-u, --unbuffered
load minimal amounts of data from the input files and flush the
output buffers more often
--help
display this help and exit
--version
output version information and exit 四、command有以下几种:
a \: append即追加字符串, a \的后面跟上字符串s(多行字符串可以用\n分隔),则会在当前选择的行的后面都加上字符串s;
c \: 取代/替换字符串,c \后面跟上字符串s(多行字符串可以用\n分隔),则会将当前选中的行替换成字符串s;
d : delete即删除,该命令会将当前选中的行删除;
i \: insert即插入字符串,i \后面跟上字符串s(多行字符串可以用\n分隔),则会在当前选中的行的前面都插入字符串s;
p : print即打印,该命令会打印当前选择的行到屏幕上;
s : 替换,通常s命令的用法是这样的:,2s/old/new/g,将old字符串替换成new字符串

learn Linux sed command的更多相关文章

  1. Linux sed command

    概述 sed 是一种在线非交互式编辑器,它一次处理一行内容. 处理时,把当前处理的行存储在临时缓冲区中,称为"模式空间"(pattern space). 接着用sed命令处理缓冲区 ...

  2. Linux sed Examples--转载

    原文地址:https://www.systemcodegeeks.com/shell-scripting/bash/linux-sed-examples/?ref=dzone Sed is basic ...

  3. linux sed命令参数及用法详解

    linux sed命令参数及用法详解 http://blog.csdn.net/namecyf/article/details/7336308 1. Sed简介 sed 是一种在线编辑器,它一次处理一 ...

  4. Linux sed命令使用方法

    sed(Stream Editor)是Linux中文本处理使用非常广泛的工具,可以对文件内容进行替换.删除.新增.选取特定行等功能.下面通过sed常用实例介绍sed命令的使用方法. sed基本语法 s ...

  5. 理解linux sed命令

    理解linux sed命令(2010-02-27 18:21:20) 标签:linuxshellsed替换 分类:革命本钱 1. Sed简介sed是一种在线编辑器,它一次处理一行内容.处理时,把当 前 ...

  6. Linux sed 替换第一次出现的字符串

    /********************************************************************************* * Linux sed 替换第一次 ...

  7. Linux:-bash: ***: command not found

    Linux:-bash: ***: command not found,系统很多命令都用不了,均提示没有此命令. 突然之间linux很多命令都用不了,均提示没有此命令. 这应该是系统环境变量出现了问题 ...

  8. linux sed 批量替换多个文件中的字符

    格式: sed -i "s/查找字段/替换字段/g" `grep 查找字段 -rl 路径` linux sed 批量替换多个文件中的字符串 sed -i "s/oldst ...

  9. 轻松学会文本处理工具之二 linux sed命令

    sed命令的语法格式: sed的命令格式: sed [option]  'sed command'filename sed的脚本格式:sed [option] -f  'sed  script'fil ...

随机推荐

  1. CSS控制滚动条的样式

    到今天(2018年10月25日)为止, 这还是chrome上的一个实验性特性: ::-webkit-scrollbar{width:4px;height:4px;} ::-webkit-scrollb ...

  2. 配置ssh秘钥登陆

    环境2台linux服务器:node1 192.168.X.234                               node2 192.168.X.242 演示用node1无密码登陆node ...

  3. Implement JSON Web Tokens Authentication in ASP.NET Web API and Identity 2.1 Part 3 (by TAISEER)

    http://bitoftech.net/2015/02/16/implement-oauth-json-web-tokens-authentication-in-asp-net-web-api-an ...

  4. Nagios安装完后status map,trends等页面访问出错之解决

    首先,可以进入/usr/local/nagios/sbin, [root@localhost sbin]# ldd statusmap.cgi linux-vdso.so. => (0x0000 ...

  5. UVa 11549 计算器谜题(Floyd判圈算法)

    https://vjudge.net/problem/UVA-11549 题意: 有一个老式计算器,只能显示n位数字,输入一个整数k,然后反复平方,如果溢出的话,计算器会显示结果的最高n位.如果一直这 ...

  6. [WCF安全1]使用basicHttpBinding构建UserName授权的WCF应用程序

    最近到了新公司,leader让我研究一下WCF的传输安全机制.以前也做过WCF的应用,但是很少涉及安全方面的东西.所以,花了三天的时间研究了一下如何在WCF的应用程序中配置安全.在这个系列文章中,我会 ...

  7. 在lnmp下开启fileinfo扩展 Ubuntu系统

    在lnmp下开启fileinfo扩展 Ubuntu系统 1.进入目录下 cd /usr/local/lnmp1.4-full/src/php-5.6.31/ext/fileinfo 2.phpize处 ...

  8. Flutter新手第一个坑:Could not find com.android.tools.lint:lint-gradle:26.1.1.

    解决方法1:修改build.gradle,注释掉jcenter(),google().使用阿里的镜像.原因是jcenter google库无法访问到导致的问题.虽然我有万能的爬墙工具,开启全局代理依然 ...

  9. spring mvc: Hibernate验证器(字段不能为空,在1-150自己)

    spring mvc: Hibernate验证器(字段不能为空,在1-150自己) 准备: 下载Hibernate Validator库 - Hibernate Validator.解压缩hibern ...

  10. python脚本9_打印斐波那契数列

    #打印斐波那契数列 f0 = 0 f1 = 1 for n in range(2,101): fn = f1 + f0 if fn <= 100: print(fn) f0 = f1 f1 = ...