博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2.shell前基础知识
阅读量:6983 次
发布时间:2019-06-27

本文共 1653 字,大约阅读时间需要 5 分钟。

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]#

      本文转自潘阔 51CTO博客,原文链接:http://blog.51cto.com/pankuo/1367492,如需转载请自行联系原作者

你可能感兴趣的文章
7z(p7zip)压缩软件在Linux下的安装和使用
查看>>
jetbrick-template 1.1.0 发布,支持 #tag, #macro, layout
查看>>
TCP的六个控制位
查看>>
进制转换
查看>>
我的友情链接
查看>>
新书上市:《FLUENT 14.0超级学习手册》
查看>>
mysql数据库query cache
查看>>
使用docker commit 来扩展一个image
查看>>
jsp 防止sql注入 之 preparestatement篇(转载)
查看>>
Linux之Ansible入门用法(实验解析)
查看>>
Linux系统如何在开机时修改root密码
查看>>
Anychat的绝对路径与相对路径
查看>>
我的友情链接
查看>>
如何使用网络库实现应用级消息收发
查看>>
Single Area OSPF
查看>>
rhel6之yum
查看>>
selenium+ant+testng测试框架简单介绍
查看>>
自己写的DBUtil数据库连接工具类
查看>>
登录多实例MySQL失败,修改密码临时解决,原因不明
查看>>
SCCM 2007 R2部署、操作详解系列之部署篇
查看>>