- cut
MacBook-Pro:20170405 qiuxuefei$ cat /etc/passwd |tail -2
_fpsd:*:265:265:FPS Daemon:/var/db/fpsd:/usr/bin/false
_timed:*:266:266:Time Sync Daemon:/var/db/timed:/usr/bin/false
MacBook-Pro:20170405 qiuxuefei$ cat /etc/passwd |tail -2 |cut -d ":" -f 1
_fpsd
_timed
MacBook-Pro:20170405 qiuxuefei$ cat /etc/passwd |tail -2 |cut -d ":" -f 1,2
_fpsd:*
_timed:*
MacBook-Pro:20170405 qiuxuefei$ cat /etc/passwd |tail -2 |cut -d ":" -f 1-3
_fpsd:*:265
_timed:*:266
MacBook-Pro:20170405 qiuxuefei$ cat /etc/passwd |tail -2 |cut -c 3
p
i
- sort
MacBook-Pro:20170405 qiuxuefei$ cat tail_passwd.log
_findmydevice:*:254:254:Find My Device Daemon:/var/db/findmydevice:/usr/bin/false
_datadetectors:*:257:257:DataDetectors:/var/db/datadetectors:/usr/bin/false
_captiveagent:*:258:258:captiveagent:/var/empty:/usr/bin/false
_ctkd:*:259:259:ctkd Account:/var/empty:/usr/bin/false
_applepay:*:260:260:applepay Account:/var/db/applepay:/usr/bin/false
_hidd:*:261:261:HID Service User:/var/db/hidd:/usr/bin/false
_cmiodalassistants:*:262:262:CoreMedia IO Assistants User:/var/db/cmiodalassistants:/usr/bin/false
_analyticsd:*:263:263:Analytics Daemon:/var/db/analyticsd:/usr/bin/false
_fpsd:*:265:265:FPS Daemon:/var/db/fpsd:/usr/bin/false
_timed:*:266:266:Time Sync Daemon:/var/db/timed:/usr/bin/false
@
*
^
<
>
1112
1212
afasfasfasfa
444232
MacBook-Pro:20170405 qiuxuefei$ sort tail_passwd.log
*
1112
1212
444232
<
>
@
^
_analyticsd:*:263:263:Analytics Daemon:/var/db/analyticsd:/usr/bin/false
_applepay:*:260:260:applepay Account:/var/db/applepay:/usr/bin/false
_captiveagent:*:258:258:captiveagent:/var/empty:/usr/bin/false
_cmiodalassistants:*:262:262:CoreMedia IO Assistants User:/var/db/cmiodalassistants:/usr/bin/false
_ctkd:*:259:259:ctkd Account:/var/empty:/usr/bin/false
_datadetectors:*:257:257:DataDetectors:/var/db/datadetectors:/usr/bin/false
_findmydevice:*:254:254:Find My Device Daemon:/var/db/findmydevice:/usr/bin/false
_fpsd:*:265:265:FPS Daemon:/var/db/fpsd:/usr/bin/false
_hidd:*:261:261:HID Service User:/var/db/hidd:/usr/bin/false
_timed:*:266:266:Time Sync Daemon:/var/db/timed:/usr/bin/false
afasfasfasfa
MacBook-Pro:20170405 qiuxuefei$ sort -n tail_passwd.log
*
<
>
@
^
_analyticsd:*:263:263:Analytics Daemon:/var/db/analyticsd:/usr/bin/false
_applepay:*:260:260:applepay Account:/var/db/applepay:/usr/bin/false
_captiveagent:*:258:258:captiveagent:/var/empty:/usr/bin/false
_cmiodalassistants:*:262:262:CoreMedia IO Assistants User:/var/db/cmiodalassistants:/usr/bin/false
_ctkd:*:259:259:ctkd Account:/var/empty:/usr/bin/false
_datadetectors:*:257:257:DataDetectors:/var/db/datadetectors:/usr/bin/false
_findmydevice:*:254:254:Find My Device Daemon:/var/db/findmydevice:/usr/bin/false
_fpsd:*:265:265:FPS Daemon:/var/db/fpsd:/usr/bin/false
_hidd:*:261:261:HID Service User:/var/db/hidd:/usr/bin/false
_timed:*:266:266:Time Sync Daemon:/var/db/timed:/usr/bin/false
afasfasfasfa
1112
1212
444232
MacBook-Pro:20170405 qiuxuefei$ sort -nr tail_passwd.log
444232
1212
1112
afasfasfasfa
_timed:*:266:266:Time Sync Daemon:/var/db/timed:/usr/bin/false
_hidd:*:261:261:HID Service User:/var/db/hidd:/usr/bin/false
_fpsd:*:265:265:FPS Daemon:/var/db/fpsd:/usr/bin/false
_findmydevice:*:254:254:Find My Device Daemon:/var/db/findmydevice:/usr/bin/false
_datadetectors:*:257:257:DataDetectors:/var/db/datadetectors:/usr/bin/false
_ctkd:*:259:259:ctkd Account:/var/empty:/usr/bin/false
_cmiodalassistants:*:262:262:CoreMedia IO Assistants User:/var/db/cmiodalassistants:/usr/bin/false
_captiveagent:*:258:258:captiveagent:/var/empty:/usr/bin/false
_applepay:*:260:260:applepay Account:/var/db/applepay:/usr/bin/false
_analyticsd:*:263:263:Analytics Daemon:/var/db/analyticsd:/usr/bin/false
^
@
>
<
*
- wc
MacBook-Pro:20170405 qiuxuefei$ cat wc.log
aaa
bbb
1233
MacBook-Pro:20170405 qiuxuefei$ wc -l wc.log 【行数】
3 wc.log
MacBook-Pro:20170405 qiuxuefei$ wc -m wc.log 【字符数,包含换行符】
13 wc.log
MacBook-Pro:20170405 qiuxuefei$ wc -w wc.log 【单词数】
3 wc.log
- uniq
MacBook-Pro:20170405 qiuxuefei$ cat 2.text
wqwq
1
2
1
MacBook-Pro:20170405 qiuxuefei$ uniq 2.text
wqwq
1
2
1
MacBook-Pro:20170405 qiuxuefei$ cat 3.text
wqwq
1
1
2
MacBook-Pro:20170405 qiuxuefei$ uniq 3.text
wqwq
1
2
MacBook-Pro:20170405 qiuxuefei$ cat 2.text
wqwq
1
2
1
qw
2
3
2
MacBook-Pro:20170405 qiuxuefei$ uniq -c 2.text
1 qq
1 wqwq
1 1
1 2
1 1
1 qq
1 qw
1 qq
1 2
1 3
1 2
MacBook-Pro:20170405 qiuxuefei$ sort 2.text |uniq -c
2 1
3 2
1 3
3 qq
1 qw
1 wqwq
- tee
sort 2.text |uniq -c tee tee.log 【输出+重定向】
sort 2.text |uniq -c tee -a. tee.log 【输出+追加重定向】
- tr
MacBook-Pro:20170405 qiuxuefei$ sort 2.text |uniq -c | tr 'q' 'Q'
2 1
3 2
1 3
3 QQ
1 Qw
1 wQwQ
MacBook-Pro:20170405 qiuxuefei$ sort 2.text |uniq -c | tr '[a-z]' '[A-Z]'
2 1
3 2
1 3
3 QQ
1 QW
1 WQWQ
- split
split -l 【按照行切割】
split -b 100 aaa.text 【按照大小切割】