xargs標準輸出作爲參數 給命令 echo file{1..10}| xargs touch

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章