2019-01-08 10:42:12 450浏览
今天扣丁学堂Linux培训老师给大家介绍一下关于Linux中“!”你不知道的惊叹用法详解,首先在Linux工作中实际上,不起眼的“!”在linux中有着很多让你惊叹的妙用。本文就来细数那些“!”的神奇用法。下面话不多说了,来一起看看详细的介绍吧。
$ whereis bash #执行命令 bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz $ !! #再次执行上一条命令 whereis bash bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
$ /opt/user/test.txt #忘记输入more $ more !! #这样是不是快多了?
$ ls /proc/1/task/1/net/tcp /proc/1/task/1/net/tc $ ls -al !$ ls -al /proc/1/task/1/net/tcp -r--r--r-- 1 root root 0 12月 22 17:30 /proc/1/task/1/net/tcp
$ ls -al !^
$ ls -al dir #假设dir是一个很长的字符串 $ !:- ls -al
$ fin -name "test.zip" #这里find输错了。 $ find !* find ./ -name "test.zip" ./workspaces/shell/find/test.zip ./workspaces/shell/test.zip
$ cp -rf dira dirb/ #将dira拷贝到dirb $ ls -l !cp:2 #查看dira的内容 ls -l dira total 0 -rw-rw-r-- 1 hyb hyb 0 12月 22 17:45 testfile
$ history (这里省略更多内容) 2043 touch ./dira/testfile 2044 cp -rf dira dirb/ 2045 ls -al dira 2046 ls -l dira 2047 ls -al dira 2048 ls -l dira 2049 ls -al dira 2050 ls -l dira 2051 history
$ !2044 #2044是执行的第n条命令 cp -rf dira dirb/
$ !-2 #感叹号后面跟着一个负数,负几代表倒数第几条
$ !find #执行上条以find开头的命令
$ find ./ -name "test" ./test ./find/test $ !?name? find ./ -name "test" ./test ./find/test
$ find ./ -name "old*" -a -name "*.zip"
$ !!:gs/old/new
rm !(*.cfg) #删除需谨慎
以上就是关于扣丁学堂Linux培训解析“!”你不知道的惊叹用法总结的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,想要了解更多内容的小伙伴可以登录扣丁学堂官网咨询。想要学好Linux开发小编给大家推荐口碑良好的扣丁学堂,扣丁学堂有专业老师制定的Linux学习路线图辅助学员学习,此外还有与时俱进的Linux视频教程供大家学习,想要学好Linux开发技术的小伙伴快快行动吧。扣丁学堂Linux技术交流群:422345477。
【关注微信公众号获取更多学习资料】