shell脚本-编程前奏-bash特性

1.命令和文件自动补全

tab只能补全命令和文件

2.常见的快捷键

^c             终止前台运行的程序

^z             将前台运行的程序

^d        退出 等价于exit

^l       清屏

^a home     光标移动到命令行的最前端

^e end      光标移动到命令行后端

^u        删除光标前所有字符

^k        删除光标后所有字符

^r         搜索历史命令

3.常用的通配符

 *:匹配0或多个任意字符

?:匹配任意单个字符

[list]:匹配[list]中任意单个字符,或者一组单个字符[a-z]

[!list]:匹配list中的任意单个字符

{string1,string2,...}:匹配string1,string2或更多字符串

# rm -f file*

# cp *.conf  /dir1

# touch file{1..5}

实战

创建多个图片

touch file{1..13}.jpg

查看图片文件

ls -l file*.jpg

查看file*

ls -l file*

ls  -l  file?.jpg

ls  -l  file1?.jpg

ls file[123].jpg

ls -l file[1-13].jpg

ls -l file[2-14].jpg

ls -l file[3-10].jpg

ls -l file[1-10].jpg

ls -l file[0-9].jpg

ls -l file[0-9,10,11].jpg

取反

ls -l file[!1234].jpg

查找字符串

ls -l file{1,2,3,11,13}.jpg

ls -l file{1..13}.jpg

4.bash中的引号

#  双引号"" :会把引号的内容当成整体来看待,允许通过$符号引用其他变量值。

#  单引号''  :会把引号的内容当成整体来看待,禁止引用其他变量值,shell中特殊符号都被视为普通字符。

#  反撇号··: 反撇号和$()一样,引号或括号里的命令会优先执行,如果存在嵌套,反撇号不能用

实战

 单双引号

 反撇号

 

posted on 2020-05-14 11:59  流着眼泪奔跑  阅读(170)  评论(0编辑  收藏  举报

导航