1.基础命令

2.通配符与转义字符

*  代表任意的字符可以是空字符串

代表一个字符但不可为空


[root@pankuo shell]# echo 9 '*' 9 =81

9 * 9 =81

[root@pankuo shell]# echo 9 '*' 9

9 * 9

[root@pankuo shell]# echo '9 * 9 = 81 '

9 * 9 = 81

[root@pankuo shell]# echo 9 \* 9

9 * 9

[root@pankuo shell]# echo 9 \* 9 =81

9 * 9 =81

[root@pankuo shell]#




[root@pankuo shell]# echo 'this is jack'sbook.'

> ^C

[root@pankuo shell]#

[root@pankuo shell]# echo 'this is jack\'sbook.'

> ^C

[root@pankuo shell]# echo 'this isjack'\''s book.'

this is jack's book.

[root@pankuo shell]#



续行字符

[root@pankuo shell]# echo "line 1 \

> line 1 too"

line 1 line 1 too

[root@pankuo shell]#


字符集合

[] 里面的代表比对的字符范围 [abc]  指代abc其中一个

[a-z] 英文小写

[A-Z] 英文大写

[a-zA-Z] 英文大小写

[0-9] 数字

[a-zA-Z0-9] 英数字

[a-z_-] 由于字符表示范围因此把-如果也纳入集和的一份子请把-放在集合的开头或结尾

[abc]  不是数字

[0-9]代表数字或感叹号

[\!0-9] 若要把!放在第一个位置就需要\!这样写


括号扩展

#ls –al /usr/bin/{g,nc,s}ftp  便可去找到gftp     ncftp   sftp 3个文件若存在的话


系统默认开启的文件

每一个shell脚本执行时系统会分别开启标准输入 0 标准输出 1 标准错误 2   后面数字是文件代码



转向输出


[root@pankuo shell]# echo 'hello world!'> hi.text

You have new mail in /var/spool/mail/root

[root@pankuo shell]# ls

clearlog.sh hello.sh  hi.text

[root@pankuo shell]#


转向附加

[root@pankuo shell]# echo 'ppp' >>hi.text

[root@pankuo shell]# cat hi.text

hello world!

ppp

[root@pankuo shell]#


转向输入


[root@pankuo shell]# cat hi.text

hello world!

ppp

[root@pankuo shell]# wc -l < hi.text

2

[root@pankuo shell]#


转向输入和转向输出合用

vim www

3

2

4

1

5

[root@pankuo shell]# sort < www >pan.txt

[root@pankuo shell]# cat pan.txt

1

2

3

4

5

[root@pankuo shell]#


管道


[root@pankuo shell]# cat www |sort >ll.txt

[root@pankuo shell]# cat ll.txt

1

2

3

4

5

[root@pankuo shell]#