擴展:正則表達式
1. source exec 區別 http://alsww.blog.51cto.com/2001924/1113112
2. Linux特殊符號大全http://ask.apelearn.com/question/7720
3. sort並未按ASCII排序 http://blog.csdn.net/zenghui08/article/details/7938975shell
[root@yong-02 test]# head -3 passwd |cut -d ":" -f 1-3 root:x:0 bin:x:1 daemon:x:2
[root@yong-02 test]# head -3 passwd |cut -d ":" -f 1,3 root:0 bin:1 daemon:2
[root@yong-02 test]# head -3 passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin [root@yong-02 test]# head -3 passwd |cut -c 3 o n e
[root@yong-02 test]# head -3 passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin [root@yong-02 test]# head -3 passwd |cut -c 2-6 oot:x in:x: aemon
[root@yong-02 test]# vim passwd adf 123 111 !!! !jk lfas <:: >, %^ root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt operator:x:11:0:operator:/root:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin polkitd:x:999:997:User for polkitd:/:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin
[root@yong-02 test]# sort -n passwd <:: >, !!! %^ adf bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin halt:x:7:0:halt:/sbin:/sbin/halt !jk lfas lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin polkitd:x:999:997:User for polkitd:/:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin root:x:0:0:root:/root:/bin/bash shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin 111 123
[root@yong-02 test]# sort -nr passwd 123 111 systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown root:x:0:0:root:/root:/bin/bash postfix:x:89:89::/var/spool/postfix:/sbin/nologin polkitd:x:999:997:User for polkitd:/:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin lfas !jk halt:x:7:0:halt:/sbin:/sbin/halt ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin bin:x:1:1:bin:/bin:/sbin/nologin adf %^ !!! >, <::
[root@yong-02 test]# sort -nu passwd adf 111 123
[root@yong-02 test]# cat 1.txt abcd 1abcd 123 111 121 [root@yong-02 test]# wc -l 1.txt 5 1.txt
[root@yong-02 test]# cat -A 1.txt abcd$ 1abcd$ 123$ 111$ 121$ [root@yong-02 test]# wc -m 1.txt 23 1.txt
[root@yong-02 test]# cat 1.txt abcd 1abcd 123 111 121 [root@yong-02 test]# wc -w 1.txt 5 1.txt
[root@yong-02 test]# cat 1.txt abcd 1abcd 123 111 121 [root@yong-02 test]# wc 1.txt 5 5 23 1.txt
[root@yong-02 test]# cat 2.txt 111 222 123 111 222 adf 123 111 !!! !jk lfas <:: >, %^ root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
[root@yong-02 test]# sort 2.txt |uniq -c 1 <:: 1 >, 1 !!! 1 %^ 3 111 2 123 2 222 1 adf 1 bin:x:1:1:bin:/bin:/sbin/nologin 1 daemon:x:2:2:daemon:/sbin:/sbin/nologin 1 !jk 1 lfas 1 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin 1 root:x:0:0:root:/root:/bin/bash 3 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
[root@yong-02 test]# cat 1.txt > a.txt [root@yong-02 test]# cat 1.txt |tee a.txt abcd 1abcd 123 111 121
[root@yong-02 test]# cat 1.txt |tee -a a.txt abcd 1abcd 123 111 121 [root@yong-02 test]# cat a.txt abcd 1abcd 123 111 121 abcd 1abcd 123 111 121
[root@yong-02 test]# cat 1.txt |tr 'a' 'A' Abcd 1Abcd 123 111 121 [root@yong-02 test]# cat 1.txt |tr 'a-z' 'A-Z' ##最好'[a-z]' '[A-Z]' ABCD 1ABCD 123 111 121
[root@yong-02 test]# find /etc/ -type f -name "*.conf" -exec cat {} >test.txt \; [root@yong-02 test]# du -sh test.txt 240K test.txt [root@yong-02 test]# split -b 100k test.txt [root@yong-02 test]# ls test.txt xab xaa xac
[root@yong-02 test]# wc -l test.txt 6082 test.txt [root@yong-02 test]# split -l 1000 test.txt [root@yong-02 test]# ls test.txt xab xad xaf xaa xac xae xag
[root@yong-02 test]# split -l 1000 test.txt abc. [root@yong-02 test]# ls abc.ab abc.ad abc.af test.txt abc.aa abc.ac abc.ae abc.ag
[root@yong-02 test]# ls /tmp/gzip/ 1.txt 2.txt.zip 4.txt test yyl.tar yyl.tar.gz yyl.zip 2.txt 3.txt 5.txt yyl yyl.tar.bz2 yyl.tar.xz [root@yong-02 test]# ls !$ ls /tmp/gzip/ 1.txt 2.txt.zip 4.txt test yyl.tar yyl.tar.gz yyl.zip 2.txt 3.txt 5.txt yyl yyl.tar.bz2 yyl.tar.xz
[root@yong-02 test]# cat 1.txt ;cat a.txt abcd 1abcd 123 111 121 abcd
~ 家目錄,後面正則表示匹配符vim
重定向(正確) > ,會覆蓋之前的內容bash
[root@yong-02 test]# echo "abcdefg" >a.txt [root@yong-02 test]# cat a.txt abcdefg
[root@yong-02 test]# echo "1234" >>a.txt [root@yong-02 test]# cat a.txt abcdefg 1234
[root@yong-02 test]# cat c.txt 2>a.txt [root@yong-02 test]# cat a.txt cat: c.txt: 沒有那個文件或目錄
[root@yong-02 test]# cat c.txt 2>>a.txt [root@yong-02 test]# cat a.txt cat: c.txt: 沒有那個文件或目錄 cat: c.txt: 沒有那個文件或目錄
[root@yong-02 test]# cat 1.txt c.txt &>a.txt [root@yong-02 test]# cat a.txt abcd 1abcd 123 111 121 cat: c.txt: 沒有那個文件或目錄