Linux 管道命令 cut 、sort 、 wc 、 split 、tr 的常用 技巧執行個體

來源:互聯網
上載者:User

Linux  sort的常用

按照第5個欄位進行排序

[root@test2 smartlsData]# ll | sort   -t : +5n
-rwxrwxrwx  1 root root 178718700 12月 22 18:40 Poi.bal
-rwxrwxrwx  1 root root 182348152 12月 22 18:40 Poi.bas
-rwxrwxrwx  1 root root  18441600 12月 22 18:40 Poi.ndx
-rwxrwxrwx  1 root root    194056 2006-08-29  wordTableEntry.txt
-rwxrwxrwx  1 root root    194056  9月 15 16:31 GeoWordTableEntry.txt
-rwxrwxrwx  1 root root     20580 12月 22 18:40 ACode.ndx
-rwxrwxrwx  1 root root    338304 2006-08-10  AnTable.txt
-rwxrwxrwx  1 root root     43680 2006-08-10  CnTable.txt
-rwxrwxrwx  1 root root   4929920 2006-08-29  wordTable.txt
-rwxrwxrwx  1 root root   4929920  9月 15 16:31 GeoWordTable.txt
-rwxrwxrwx  1 root root      6664  9月 14 16:25 data.xml
-rwxrwxrwx  1 root root   9220800 12月 22 18:40 LsID.idx 

按照純數字進行排序(否則按照字母方式進行排序)

[root@test2 smartlsData]# ll | sort -n
-rwxrwxrwx  1 root root 178718700 12月 22 18:40 Poi.bal
-rwxrwxrwx  1 root root 182348152 12月 22 18:40 Poi.bas
-rwxrwxrwx  1 root root  18441600 12月 22 18:40 Poi.ndx
-rwxrwxrwx  1 root root    194056 2006-08-29  wordTableEntry.txt
-rwxrwxrwx  1 root root    194056  9月 15 16:31 GeoWordTableEntry.txt
-rwxrwxrwx  1 root root     20580 12月 22 18:40 ACode.ndx
-rwxrwxrwx  1 root root    338304 2006-08-10  AnTable.txt
-rwxrwxrwx  1 root root     43680 2006-08-10  CnTable.txt
-rwxrwxrwx  1 root root   4929920 2006-08-29  wordTable.txt
-rwxrwxrwx  1 root root   4929920  9月 15 16:31 GeoWordTable.txt
-rwxrwxrwx  1 root root      6664  9月 14 16:25 data.xml
-rwxrwxrwx  1 root root   9220800 12月 22 18:40 LsID.idx
總用量 390484

 

Linux  wc 的使用

wc -l  行號

wc -m

wc -w

[root@test2 smartlsData]# ll | wc -l
13

替換

[root@test2 smartlsData]# ll | tr -d  'A'
總用量 390484
-rwxrwxrwx  1 root root     20580 12月 22 18:40 Code.ndx
-rwxrwxrwx  1 root root    338304 2006-08-10  nTable.txt
-rwxrwxrwx  1 root root     43680 2006-08-10  CnTable.txt
-rwxrwxrwx  1 root root      6664  9月 14 16:25 data.xml
-rwxrwxrwx  1 root root    194056  9月 15 16:31 GeoWordTableEntry.txt
-rwxrwxrwx  1 root root   4929920  9月 15 16:31 GeoWordTable.txt
-rwxrwxrwx  1 root root   9220800 12月 22 18:40 LsID.idx
-rwxrwxrwx  1 root root 178718700 12月 22 18:40 Poi.bal
-rwxrwxrwx  1 root root 182348152 12月 22 18:40 Poi.bas
-rwxrwxrwx  1 root root  18441600 12月 22 18:40 Poi.ndx
-rwxrwxrwx  1 root root    194056 2006-08-29  wordTableEntry.txt
-rwxrwxrwx  1 root root   4929920 2006-08-29  wordTable.txt

[root@test2 smartlsData]# ll | cut -d " " -f 4
 
root
root
root
root
root
root
root
root
root
root
root
root

拆分 按照大小 和 行 來拆分

split -b 1m detailWebsite.htm detailWebsite.htm_
split -l 5 detailWebsite.htm detailWebsite.htm_

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.