博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【CentOS 7笔记32】,通配符、输入输出重定向#171116
阅读量:6893 次
发布时间:2019-06-27

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

hot3.png

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

转载于:https://my.oschina.net/hellopasswd/blog/1574237

你可能感兴趣的文章
@Scheduled cronExpression表达式
查看>>
放射科医生可零门槛调用AI算法:美国放射学会发布人工智能开放平台
查看>>
谷歌智能音箱更新,玩转摄像头,但名归Nest麾下
查看>>
注册URL Scheme
查看>>
人工智能照进三百六十行:百度大脑与劳动者们
查看>>
多线程基础(七)GCD线程组+栅栏函数
查看>>
从濒临倒闭到狂赚50万,发生了什么?
查看>>
学习笔记-linux文件特殊基本权限基础
查看>>
Spring quartz的Job中如何获取Spring上下文
查看>>
FTP服务
查看>>
C#判断IP是否是指定范围内的IP
查看>>
TEC-005-cifs-Host is down
查看>>
saltstack模块之pkg相关模块
查看>>
linux查看内核版本号
查看>>
SVN合代码时遇到的问题
查看>>
tuna.tsinghua yum repo
查看>>
ext store remove old datas load new datas优化
查看>>
【Jetty Server 开发系列之一】搭建Jetty Server环境&&Http客户端实现交互
查看>>
【COCOS2D-HTML5 开发之三】示例项目附源码及运行的GIF效果图
查看>>
mysql5.6的安装(rpm)
查看>>