15-Linux不会别做运维-find与sed

其它特殊字符:
; 命令结尾
‘# 注释 管理员提示符
$ 调用变量 普通用户提示符
\ 转义字符 取消别名
{ } 生成序列 分割变量和变通字符
& 执行脚本时候把脚本放入后台

find . -type f -name "[abcd]" |grep "a"

重定向系统:
0 标准输入
1 标准输出
2 错误输出

箭头方向是数据流向;

‘ > 和 1> 输出重定向,内容追加到结尾
2> 错误输出重定向,清空内容

’ >> 1>> 追加输出重定向,内容追加到结尾
2>> 错误追加输出重定向,内容追加到结尾

以下3种用法是等价的:
echo "111" 1>>exam.txt 2>>feiliu.txt
echo "111" 1>>exam.txt 2>&1 第二种方法
echo "111" &>>exam.txt

echo "111" 2>>exam.txt 1>&2

<或0< 标准输入重定向
<< 或0<<

cat >>exam.txt<<EOF
d tve qy tve qy c ue
e g ywwf mm
mmm jfd e wh w
EOF

ls |xargs rm -f 相当于: rm -f a b c

[root@manager ~/exam]$ touch a b c 
[root@manager ~/exam]$ ll
total 0
-rw-r--r--. 1 root root 0 Dec  5 18:57 a
-rw-r--r--. 1 root root 0 Dec  5 18:57 b
-rw-r--r--. 1 root root 0 Dec  5 18:57 c
[root@manager ~/exam]$ ls |xargs rm -f
[root@manager ~/exam]$ ll
total 0
find /exam/  -type f -name "[1-9]"|xargs rm -f 
原理:  rm -f 1 2 3
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章