关闭

Unix Sed

标签: unixsystemdeletecharactereach
1280人阅读 评论(1) 收藏 举报
分类:
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.

$
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:25024次
    • 积分:345
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:14篇
    • 译文:0篇
    • 评论:1条
    文章分类
    文章存档
    最新评论