系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > 系统帮助 > 详细页面

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

时间:2020-02-19来源:系统城作者:电脑系统城

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目录的目录

分享到:

相关信息

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载