码迷,mamicode.com
首页 > 其他好文 > 详细

xargs标准输出作为参数 给命令 echo file{1..10}| xargs touch

时间:2020-02-19 15:16:30      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:str   chmod   查看   time   用户   cal   txt   find   输出   

xargs标准输出作为参数 给命令

echo file{1..10}| xargs touch

file1 ...file10 作为文件名 被xargs 一个一个传给 touch

echo {1..10} |xargs -n 2 echo

配置 1 2 之后就换行

[07:29:04 root@localhost /]$echo {1..10} | xargs -n 2 echo

1 2
3 4
5 6
7 8
9 10

[07:30:11 root@localhost /]$echo {1..10} | xargs -n 1 echo --加 "-n" 制定几个数值作为参数 这里执行 一个数字为 参数

1
2
3
4
5
6
7
8
9
10
[07:30:29 root@localhost /]$

[07:38:38 root@localhost /]$ll /home
total 4
drwx------. 3 test test 78 Feb 17 01:05 test
drwx------. 3 zhong1 zhong1 78 Feb 17 07:35 zhong1
drwx------. 3 zhong10 zhong10 78 Feb 17 07:35 zhong10
drwx------. 3 zhong2 zhong2 78 Feb 17 07:35 zhong2
drwx------. 3 zhong3 zhong3 78 Feb 17 07:35 zhong3
drwx------. 3 zhong4 zhong4 78 Feb 17 07:35 zhong4
drwx------. 3 zhong5 zhong5 78 Feb 17 07:35 zhong5
drwx------. 3 zhong6 zhong6 78 Feb 17 07:35 zhong6
drwx------. 3 zhong7 zhong7 78 Feb 17 07:35 zhong7
drwx------. 3 zhong8 zhong8 78 Feb 17 07:35 zhong8
drwx------. 3 zhong9 zhong9 78 Feb 17 07:35 zhong9
drwx------. 15 zhonghua zhonghua 4096 Feb 16 16:25 zhonghua

[07:38:46 root@localhost /]$echo zhong{1..10}| xargs -n 1 userdel -r ---删除用户及家目录

find /etc -perm /700 | xargs ls -l /etc下文件所有者具备读或写或执行的权限 文件作为参数传给 ls -l

[10:05:38 root@localhost test1]$ls

2}.txt fb.txt fd.txt fg.txt fj.txt fm.txt fp.txt fs.txt fv.txt fy.txt
fa.txt f c.txt fe.txt fh.txt fk.txt fn.txt fq.txt ft.txt fw.txt fz.txt
f{a..z fc.txt ff.txt fi.txt fl.txt fo.txt fr.txt fu.txt fx.txt
[10:05:48 root@localhost test1]$find -name "f.txt" -print0 |xargs -0 rm ---print0 以16进制0为分隔符 ;Xargs -0 (告知指定参数 0 为分隔符)
[10:06:22 root@localhost test1]$ll
total 0
-rw-r--r--. 1 root root 0 Feb 17 10:04 2}.txt
-rw-r--r--. 1 root root 0 Feb 17 10:04 f{a..z
[10:06:24 root@localhost test1]$

find /tmp -ctime +3 -user zhonghua -ok rm {} \; 查找zhonghua 三天以上的文件并删除 --需要手动确认

find /tmp -ctime +3 -user zhonghua -exec rm {} \; 不进攻确认直接删除

find ~ -perm -002 -exec chmod o-w {} \; --在主目录寻找可被其他用户写入的文件 并删除other写入权限

find /home -type d -ls 查看home目录的目录

xargs标准输出作为参数 给命令 echo file{1..10}| xargs touch

标签:str   chmod   查看   time   用户   cal   txt   find   输出   

原文地址:https://blog.51cto.com/12246080/2472109

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!