Unix Sed

转载 2006年05月18日 18:43:00
sed '5d' Delete line 5

sed '/[Tt]est/d' Delete all lines containing Test or test

sed -n '20,25p' text Print only lines 20 through 25 from text

sed '1,10s/unix/UNIX/g' intro Change unix to UNIX wherever it appears in the first 10 lines of intro

sed '/jan/s/-1/-5/' Change the first -1 to -5 on all lines containing jan

sed 's/...//' data Delete the first three characters from each line of data

sed 's/...$//' data Delete the last 3 characters from each line of data

sed -n 'l' text Print all lines from text, showing nonprinting characters as /nn (where nn is the octal value of the character), and tab characters as /t


$ cat intro
The Unix operating system was pioneered by Ken
Thompson and Dennis Ritchie at Bell Laboratories
in the late 1960s. One of the primary goals in
the design of the Unix system was to create an
environment that promoted efficient program
development.

$

$ sed 's/Unix/UNIX/' intro Substitute Unix with UNIX

The UNIX operating system was pioneered by Ken
Thompson and Dennis Ritchie at Bell Laboratories
in the late 1960s. One of the primary goals in
the design of the UNIX system was to create an
environment that promoted efficient program
development.
$

$ sed -n '1,2p' intro Just print the first 2 lines

The UNIX operating system was pioneered by Ken
Thompson and Dennis Ritchie at Bell Laboratories

$

$ sed -n '/UNIX/p' intro Just print lines containing UNIX

The UNIX operating system was pioneered by Ken
the design of the UNIX system was to create an

$

$ sed '1,2d' intro Delete lines 1 and 2

in the late 1960s. One of the primary goals in
the design of the UNIX system was to create an
environment that promoted efficient program
development.

$

$ sed '/UNIX/d' intro Delete all lines containing UNIX

Thompson and Dennis Ritchie at Bell Laboratories
in the late 1960s. One of the primary goals in
environment that promoted efficient program
development.

$

相关文章推荐

UNIX 下SED使用全解手册

  • 2013年12月21日 02:16
  • 56KB
  • 下载

UNIX 下SED使用全解手册

URL: http://www.chinaitpower.com/2005September/2005-09-13/203731.html SED 手册 - 1. Introduction 来...

Linux/Unix Sed与awk 中文第三版

  • 2014年10月07日 19:01
  • 12.04MB
  • 下载

Unix流编辑器sed实例+(全三部分)

  • 2011年11月08日 10:06
  • 179KB
  • 下载

UNIX的sed命令

转载:http://blog.chinaunix.net/uid-790245-id-2037366.html sed是一个非交互性性文本编辑器,它编辑文件或标准输入导出的文件拷贝。标准输入可能是来自...

Linux/Unix sed命令中文详解图

  • 2014年09月01日 15:55
  • 587KB
  • 下载

unix: 从文本中截取指定匹配行(sed的用法)

首先准备一段文本:test01.txt begin how are you? fine thank you,and you? i am fine too. end ^Bbegin ple...

Unix Sed Tutorial: Printing File Lines using Address and Patterns

Unix Sed Tutorial: Printing File Lines using Address and PatternsUnix Sed Introductionsed is a “non-...

linux/unix命令详解之sed

ps:我只能说别说你会sed。。。这篇综合很多sed文档写成。 1. 功能说明:利用script来处理文本文件。 语  法:sed [-hnV][-e(script)][-f (script文...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Unix Sed
举报原因:
原因补充:

(最多只允许输入30个字)