2011年11月15日 星期二

Linux Pipe小工具

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 -l13
替換
[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
 
rootrootrootrootrootrootrootrootrootrootrootroot
拆分 按照大小 和 行 來拆分
split -b 1m detailWebsite.htm detailWebsite.htm_split -l 5 detailWebsite.htm detailWebsite.htm_

沒有留言: