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. shell脚本中使用什么工具进行计算

    1.答: expr 2. expr的用法: jello=$(expr 1 \* 3) //乘法,注意1和expr之间有空格,1与转换符\之间有空格,3和*之间有空格 jello=$(expr 1 / ...

  2. 爬虫之JSON

    数据提取之JSON与JsonPATH JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,它使得人们很容易的进行阅读和编写.同时也方便了机器进行解析和生成.适 ...

  3. spark(二)优化思路

    优化思路 内存优化 内存优化大概分为三个方向 1.所有对象的总内存(包括数据和java对象) 2.访问这些对象的开销 3.垃圾回收的开销 其中Java的原生对象往往都能被很快的访问,但是会多占据2-5 ...

  4. 4.scala中的类

    版权申明:转载请注明出处.文章来源:http://bigdataer.net/?p=269 排版乱?请移步原文获得更好的阅读体验 1.针对不同字段生成的方法 字段生成的方法备注 var/val nam ...

  5. linux一键安装mysql脚本

    #!/bin/sh if [ -s /etc/my.cnf ];then rm -rf /etc/my.cnf fi echo "------------------------------ ...

  6. Visual Studio 2013 Ultimate & IIS Express 8.0 错误 [iisexpress.exe”已退出,返回值为 -1073741816 (0xc0000008)] 解决方法

    1. 开发环境 Visual Studio 2013 Ultimate IIS 8.0 Express 2. 错误信息 错误提示:iisexpress.exe”已退出,返回值为 -1073741816 ...

  7. uva11183最小树形图

    本来看数据用临界矩阵可能会超时,还是写了临界矩阵,结果1A了 模板的不能再模板 了 #include<map> #include<set> #include<cmath& ...

  8. linux下如何安装lua

    1.下载lua包并解压 wget -c http://www.lua.org/ftp/lua-5.3.0.tar.gz  tar zxvf lua-5.3.0.tar.gz 2.下载libreadli ...

  9. HDU 5698 大组合数取模(逆元)

    瞬间移动 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  10. 捕获enter键盘事件绑定到登录按钮

    /** *捕获enter键盘事件绑定到登录按钮 */ function keyLogin(event) { if (event.keyCode == 13) { document.getElement ...