hellopasswd
通配符
[root@localhost ~]# ls
111 1.txt 222 2.txt 3.txt abc anaconda-ks.cfg b.txt
123 1.txt.tar 222.zip 333 9.txt abc.txt a.txt text.txt.bz2
[root@localhost ~]# ls *txt #以txt为后缀的所有字符的文件或目录
1.txt 2.txt 3.txt 9.txt abc.txt a.txt b.txt
[root@localhost ~]# ls *txt* #以中间字符为txt的所有字符的文件或目录
1.txt 1.txt.tar 2.txt 3.txt 9.txt abc.txt a.txt b.txt text.txt.bz2
[root@localhost ~]# ls ?.txt #以txt为后缀的一个或零个任意字符的文件或目录
1.txt 2.txt 3.txt 9.txt a.txt b.txt
[root[@localhost](https://my.oschina.net/u/570656) ~]# ls [13].txt
1.txt 3.txt
[root[@localhost](https://my.oschina.net/u/570656) ~]# ls [29].txt
2.txt 9.txt
[root[@localhost](https://my.oschina.net/u/570656) ~]# ls [0-9].txt #指范围
1.txt 2.txt 3.txt 9.txt
[root[@localhost](https://my.oschina.net/u/570656) ~]# ls [0-9a-z].txt
1.txt 2.txt 3.txt 9.txt a.txt b.txt
[root[@localhost](https://my.oschina.net/u/570656) ~]# ls {2,9,b}.txt #如同[29b].txt
2.txt 9.txt b.txt
输入输出重定向
正确输入重定向>
[root@localhost ~]# echo helloworld > 1.txt
[root@localhost ~]# cat 1.txt
helloworld
[root@localhost ~]# echo helloworld > 1.txt
[root@localhost ~]# cat 1.txt
helloworld
正确追加输入重定向>>
[root@localhost ~]# echo helloworld >> 1.txt
[root@localhost ~]# echo helloworld >> 1.txt
[root@localhost ~]# cat 1.txt
helloworld
helloworld
helloworld
错误输入重定向2>
[root@localhost ~]# la / > 1.txt
-bash: la: command not found
[root@localhost ~]# cat 1.txt
[root@localhost ~]# la / 2> 1.txt
[root@localhost ~]# cat 1.txt
-bash: la: command not found
错误追加输入重定向2>>
[root@localhost ~]# la / 2>> 1.txt
[root@localhost ~]# la / 2>> 1.txt
[root@localhost ~]# cat 1.txt
-bash: la: command not found
-bash: la: command not found
-bash: la: command not found
正确和错误输入重定向&>
[root@localhost ~]# ls
111 1.txt 222 2.txt 3.txt abc anaconda-ks.cfg b.txt
123 1.txt.tar 222.zip 333 9.txt abc.txt a.txt text.txt.bz2
[root@localhost ~]# ls 111.txt 111
ls: cannot access 111.txt: No such file or directory
111:
[root@localhost ~]# ls 111.txt 111 &> 1.txt
[root@localhost ~]# cat 1.txt
ls: cannot access 111.txt: No such file or directory
111:
正确和错误追加输入重定向&>>
[root@localhost ~]# ls 111.txt 111 &>> 1.txt
[root@localhost ~]# ls 111.txt 111 &>> 1.txt
[root@localhost ~]# cat 1.txt
ls: cannot access 111.txt: No such file or directory
111:
ls: cannot access 111.txt: No such file or directory
111:
ls: cannot access 111.txt: No such file or directory
111:
输出重定向
[root@localhost ~]# wc -l 1.txt
6 1.txt
[root@localhost ~]# wc -l < 1.txt
6
[root@localhost ~]# 2.txt < 1.txt #左边必须为命令
-bash: 2.txt: command not found
以此类推
修改于171116