中文字幕亚洲第一精品|精品国产免费一区二区|久久婷婷五月六月综合版|中文字幕熟妇久久久人妻|久久综合精品国产一区无码|国产成人精品永久免费视频|午夜亚洲国产精品理论片a级|久久精品一区二区三区无码护土

 訪問手機(jī)版  

Linux常用命令|Linux培訓(xùn)學(xué)習(xí)|考試認(rèn)證|工資待遇與招聘,認(rèn)準(zhǔn)超級網(wǎng)工!

招聘|合作 登陸|注冊

網(wǎng)絡(luò)工程師培訓(xùn)

當(dāng)前位置:網(wǎng)絡(luò)工程師 > 技術(shù)課程 > linux > 熱點(diǎn)關(guān)注 > linux常用命令

Linux常用基本命令:三劍客命令之

時(shí)間:2019-11-21

常用dos命令大全_linux常用命令_linux命令vi進(jìn)入后命令

sed是一個很強(qiáng)大的文件處理工具,主要是以行為單位進(jìn)行處理,可以將數(shù)據(jù)行進(jìn)行替換、刪除、新增、選取等特定工作

格式:sed [option] [command] [file]

常用命令:

a ∶新增

c ∶取代

d ∶刪除

i ∶插入

常用dos命令大全_linux命令vi進(jìn)入后命令_linux常用命令

p∶列印

s∶取代

選項(xiàng):

-i∶直接修改讀取的檔案內(nèi)容,而不是由螢?zāi)惠敵觥?/p>

-n∶使用安靜(silent)模式。在一般 sed 的用法中,所有來自 STDIN的資料一般都會被列出到螢?zāi)簧稀5绻由?-n 參數(shù)后,則只有經(jīng)過sed 特殊處理的那一行(或者動作)才會被列出來。

1,sed '1d' ghostwu.com d代表刪除 d前面的數(shù)字代表刪除第一行,該命令不會修改文件本身

ghostwu@dev:~/linux/sed$ cat -n ghostwu.txt 
     1    this is ghostwu
     2    how are you
     3    hod old are you
     4    and you
     5    fine thank you
     6    come with me!!!
ghostwu@dev:~/linux/sed$ sed '1d' ghostwu.txt 
how are you
hod old are you
and you
fine thank you
come with me!!!
ghostwu@dev:~/linux/sed$ cat ghostwu.txt 
this is ghostwu
how are you
hod old are you
and you
fine thank you
come with me!!!

linux常用命令_常用dos命令大全_linux命令vi進(jìn)入后命令

2,刪除最后一行,$代表最后一行

ghostwu@dev:~/linux/sed$ cat ghostwu.txt 
this is ghostwu
how are you
hod old are you
and you
fine thank you
come with me!!!
ghostwu@dev:~/linux/sed$ sed '$d' ghostwu.txt 
this is ghostwu
how are you
hod old are you
and you
fine thank you

3,刪除第一行到第二行

ghostwu@dev:~/linux/sed$ cat ghostwu.txt 
this is ghostwu
how are you
hod old are you
and you
fine thank you
come with me!!!
ghostwu@dev:~/linux/sed$ sed '1,2d' ghostwu.txt 
hod old are you
and you
fine thank you
come with me!!!

4,刪除第二行到最后一行

ghostwu@dev:~/linux/sed$ sed '2,$d' ghostwu.txt 
this is ghostwu

5,查找包含'you'的行,/you/ 這是正則表達(dá)式, p是打印,要跟n結(jié)合起來用

linux命令vi進(jìn)入后命令_linux常用命令_常用dos命令大全

ghostwu@dev:~/linux/sed$ cat ghostwu.txt 
this is ghostwu
how are you
hod old are you
and you
fine thank you
come with me!!!
ghostwu@dev:~/linux/sed$ sed -n '/you/p' ghostwu.txt 
how are you
hod old are you
and you
fine thank you
 上一個教程:整理一下Linux常用命令