婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Linux paste命令的使用方法

Linux paste命令的使用方法

熱門標(biāo)簽:地圖標(biāo)注能更改嗎 高德地圖標(biāo)注公司需要錢 廈門防封電銷電話卡 宜賓銷售外呼系統(tǒng)軟件 云南電商智能外呼系統(tǒng)哪家好 地圖標(biāo)注員有發(fā)展前景嗎 四川保險(xiǎn)智能外呼系統(tǒng) 濰坊寒亭400電話辦理多少錢 外呼系統(tǒng)全國

01. 命令概述

paste命令會把每個文件以列對列的方式,一列列地加以合并 ,他就是相當(dāng)于把兩個不同的文件內(nèi)容粘貼在一起,形成新的文件。

注意:paste默認(rèn)粘貼方式以列的方式粘貼,但是并不是不能以行的方式粘貼,加上-s選項(xiàng)就可以行方式粘貼。

02. 命令格式

用法:paste [選項(xiàng)]... [文件]...

03. 常用選項(xiàng)

將每個指定文件里的每一行整合到對應(yīng)一行里寫到標(biāo)準(zhǔn)輸出,之間用制表符分隔。
如果沒有指定文件,或指定文件為"-",程序?qū)臉?biāo)準(zhǔn)輸入讀取數(shù)據(jù)。

長選項(xiàng)必須使用的參數(shù)對于短選項(xiàng)時也是必需使用的。
  -d, --delimiters=列表 改用指定列表里的字符替代制表分隔符
  -s, --serial  不使用平行的行目輸出模式,而是每個文件占用一行
      --help  顯示此幫助信息并退出
      --version  顯示版本信息并退出

04. 參考示例

文件內(nèi)容如下

[deng@localhost test]$ cat file1
1
2
3
4
5
6
[deng@localhost test]$ cat file2
AA
BB
CC
DD
EE
FF
[deng@localhost test]$ 

 4.1 合并兩個文件

[deng@localhost test]$ paste file1 file2
1    AA
2    BB
3    CC
4    DD
5    EE
6    FF
[deng@localhost test]$ 

可以看出 默認(rèn)使用制表符分隔

[deng@localhost test]$ paste file1 file2 | sed -n l
1\tAA$
2\tBB$
3\tCC$
4\tDD$
5\tEE$
6\tFF$
[deng@localhost test]$ 

4.2 指定字符代表制表符作為分隔符

[deng@localhost test]$ paste -d '*' file1 file2
1*AA
2*BB
3*CC
4*DD
5*EE
6*FF
[deng@localhost test]$ 

4.3 每個文件合并成行而不是按行粘貼。(行列轉(zhuǎn)置會用到)

[deng@localhost test]$ paste -s -d '*' file1 file2
1*2*3*4*5*6
AA*BB*CC*DD*EE*FF
[deng@localhost test]$ 

要注意一點(diǎn),此處一定要把星號用引號括起來(單引號雙引號均可),否則 Shell]會把星號擴(kuò)展為當(dāng)前目錄下的文件列表,千萬小心。

4.4 行列倒轉(zhuǎn)

[deng@localhost test]$ paste -s file1
1    2    3    4    5    6
[deng@localhost test]$ 

4.5 兩個文件行數(shù)不同

[deng@localhost test]$ paste file1 file2
1    AA
2    BB
3    CC
4    DD
5    EE
6    FF
7
[deng@localhost test]$ 

注意, 參數(shù)的順序?qū)敵鍪怯杏绊懙?/p>

[deng@localhost test]$ paste file2 file1
AA   1
BB   2
CC   3
DD   4
EE   5
FF   6
    7
[deng@localhost test]$ 

4.6 拼接多個文件

[deng@localhost test]$ paste file1 file2 file3
1    AA   aa
2    BB   bb
3    CC   cc
4    DD   dd
5    EE   ee
6    FF   ff
7
[deng@localhost test]$ 

paste 好強(qiáng)大,多個文件,照樣能夠按行拼接。而且會發(fā)現(xiàn),paste 拼接是和文件列表的順序有關(guān)的。

paste命令還有一個很有用的選項(xiàng)(-)。意即對每一個(-),從標(biāo)準(zhǔn)輸入中讀一次數(shù)據(jù)。使用空格作域分隔符,以一個6列格式顯示目錄列表。方法如下:

[root@master etc]# cat /etc/passwd|head -n 5|cut -d : -f 1,3-5|paste -d@ - - -
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon
adm:3:4:adm@lp:4:7:lp@
[root@master etc]# cat /etc/passwd|head -n 5|cut -d : -f 1,3-5|paste -d@ - - - 
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon
adm:3:4:adm@lp:4:7:lp@
[root@master etc]# cat /etc/passwd|head -n 5|cut -d : -f 1,3-5|paste -d@ - - - -
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon@adm:3:4:adm
lp:4:7:lp@@@
[root@master etc]# cat /etc/passwd|head -n 5|cut -d : -f 1,3-5|paste -d@ - - - - -
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon@adm:3:4:adm@lp:4:7:lp
[root@master etc]# cat /etc/passwd|head -n 5|cut -d : -f 1,3-5|paste -d@ - - - - - -
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon@adm:3:4:adm@lp:4:7:lp@
[root@master etc]# cat /etc/passwd|cut -d : -f 1,3-5|paste -d@ - - - - - -
root:0:0:root@bin:1:1:bin@daemon:2:2:daemon@adm:3:4:adm@lp:4:7:lp@sync:5:0:sync
shutdown:6:0:shutdown@halt:7:0:halt@mail:8:12:mail@uucp:10:14:uucp@operator:11:0:operator@games:12:100:games
gopher:13:30:gopher@ftp:14:50:FTP User@nobody:99:99:Nobody@dbus:81:81:System message bus@usbmuxd:113:113:usbmuxd user@avahi-autoipd:170:170:Avahi IPv4LL Stack
vcsa:69:69:virtual console memory owner@rtkit:499:497:RealtimeKit@abrt:173:173:@haldaemon:68:68:HAL daemon@saslauth:498:76:"Saslauthd user"@postfix:89:89:
ntp:38:38:@apache:48:48:Apache@avahi:70:70:Avahi mDNS/DNS-SD Stack@pulse:497:496:PulseAudio System Daemon@gdm:42:42:@sshd:74:74:Privilege-separated SSH
tcpdump:72:72:@zookeeper:500:500:zookeeper@hadoop:501:501:@@@

到此這篇關(guān)于Linux paste命令的使用方法的文章就介紹到這了,更多相關(guān)Linux paste命令內(nèi)容請搜素腳本之家以前的文章或下面相關(guān)文章,希望大家以后多多支持腳本之家!

標(biāo)簽:回訪 巴彥淖爾 德州 廣安 紅河 廊坊 滁州 湛江

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux paste命令的使用方法》,本文關(guān)鍵詞  Linux,paste,命令,的,使用方法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Linux paste命令的使用方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于Linux paste命令的使用方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 明星| 香河县| 泽州县| 云浮市| 贺州市| 布尔津县| 嘉禾县| 洪雅县| 文安县| 合水县| 阿克苏市| 西乌| 丹江口市| 金川县| 沾化县| 盐池县| 白水县| 黑龙江省| 本溪| 加查县| 黄龙县| 马龙县| 嘉鱼县| 乐山市| 邵阳市| 永宁县| 阿拉善右旗| 银川市| 都江堰市| 巴楚县| 托里县| 灵宝市| 蕉岭县| 徐水县| 衡阳市| 女性| 平昌县| 宁南县| 五家渠市| 凤台县| 镇远县|