系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux find命令與xargs組合使用

Linux find命令與xargs組合使用的方法(2)

時(shí)間:2014-12-31 17:57:43 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20141231/33885.html 手機(jī)查看 評(píng)論

  實(shí)例3:在當(dāng)前目錄下查找所有用戶具有讀、寫和執(zhí)行權(quán)限的文件,并收回相應(yīng)的寫權(quán)限

  命令:

  代碼如下:

  find 。 -perm -7 -print | xargs chmod o-w

  輸出:

  代碼如下:

  [root@localhost test]# ll

  總計(jì) 312

  -rw-r--r-- 1 root root 302108 11-03 06:19 log2012.log

  -rw-r--r-- 1 root root 0 11-12 22:25 log2013.log

  -rw-r--r-- 1 root root 0 11-12 22:25 log2014.log

  drwxr-xr-x 6 root root 4096 10-27 01:58 scf

  drwxrwxrwx 2 root root 4096 11-12 19:32 test3

  drwxrwxrwx 2 root root 4096 11-12 19:32 test4

 。踨oot@localhost test]# find 。 -perm -7 -print | xargs chmod o-w

 。踨oot@localhost test]# ll

  總計(jì) 312

  -rw-r--r-- 1 root root 302108 11-03 06:19 log2012.log

  -rw-r--r-- 1 root root 0 11-12 22:25 log2013.log

  -rw-r--r-- 1 root root 0 11-12 22:25 log2014.log

  drwxr-xr-x 6 root root 4096 10-27 01:58 scf

  drwxrwxr-x 2 root root 4096 11-12 19:32 test3

  drwxrwxr-x 2 root root 4096 11-12 19:32 test4

 。踨oot@localhost test]#

  說明:

  執(zhí)行命令后,文件夾scf、test3和test4的權(quán)限都發(fā)生改變

  實(shí)例4:用grep命令在所有的普通文件中搜索hostname這個(gè)詞

  命令:

  代碼如下:

  find 。 -type f -print | xargs grep “hostname”

  輸出:

  代碼如下:

 。踨oot@localhost test]# find 。 -type f -print | xargs grep “hostname”

  。/log2013.log:hostnamebaidu=baidu.com

  。/log2013.log:hostnamesina=sina.com

  。/log2013.log:hostnames=true[root@localhost test]#

  實(shí)例5:用grep命令在當(dāng)前目錄下的所有普通文件中搜索hostnames這個(gè)詞

  命令:

  代碼如下:

  find 。 -name \* -type f -print | xargs grep “hostnames”

  輸出:

  代碼如下:

 。踨oot@peida test]# find 。 -name \* -type f -print | xargs grep “hostnames”

  。/log2013.log:hostnamesina=sina.com

  。/log2013.log:hostnames=true[root@localhost test]#

  說明:

  注意,在上面的例子中, \用來取消find命令中的*在shell中的特殊含義。

發(fā)表評(píng)論

0

沒有更多評(píng)論了

評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解

立即評(píng)論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄