cut -d '分隔符號'-f fields
root@timfeng-desktop:~#echo$PATH
/usr/lib/jvm/jdk1.7.0_09/bin:/usr/share/ant/bin:/root/Downloads/android-sdk-linux/platform-tools:/usr/bin:/bin:
root@timfeng-desktop:~#echo $PATH | cut -d ':' -f 1
/usr/lib/jvm/jdk1.7.0_09/bin
root@timfeng-desktop:~#echo $PATH | cut -d ':' -f 1,5
/usr/lib/jvm/jdk1.7.0_09/bin:/bin
-c以字符串單位截取固定區間的字符
root@timfeng-desktop:~# export|cut -c 1-5
decla
decla
decla
grep
剛剛的cut是就將一行訊息當中,取出我們想要的,而grep則是分析一行訊息,若當中有我們所需要的信息,就將改行拿出來
grep [-acinv] [--color=auto]'搜尋字符串'filename
root@timfeng-desktop:/etc#last|grep --color=auto 'root' <==查詢含有root的數據
root pts/0 :0.0 Tue Feb 5 15:20 still logged in
sort [-fbMntuK] [file or stdin]
-f 忽略大小寫差異,
-b:忽略前面的空格部分
-M以月份的名字排序,
-n使用數字進行排序
-r 反向排序
-u uniq相同的數據中僅現一行代表
-t 分隔符,預設tab鍵來分隔
-K 以哪個區間來進行排序
cat /etc/passwd | sort -t':' -k 3
把passwd打印出來之後排序用“:”風格並且取第三那個字符
root@timfeng-desktop:/etc#last|cut -d ' ' -f1|sort|uniq -c
1
2 reboot
13 root
1wtmp
僅顯示登陸賬戶,並且只顯示一次,並且統計顯示的次數
WC:
列出行數,字數,字符數
/etc# cat/etc/manpath.config |wc
131 715 5173
tee 會同事吧數據流分到檔案於屏幕
tee [-a] file
-a用累加的方式加
last|tree last.list|cut -d ' '-f1 <==讓我們可以將last的輸出輸入到文件last.list中
tr
可以用來刪除一段訊息當中的文字,或者是進行文字訊息的替換
tr[-ds] SET1
-d: 刪除訊息當中的SET1這個字符串
-s 取代掉重複字符串
root@timfeng-desktop:~# cat/etc/passwd|tr -d ':'
將/etc/passwd輸出的訊息中,將冒號刪除
join命令
功能:“將兩個文件中指定欄位相同的行連接起來”,即按照兩個文件中共同擁有的某一列,將對應的行拼接成一行。
join[options] file1 file2
paste[-d] file1 file2
將兩個文件相同行連接在一起