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

當前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux find命令-exec參數的作用

Linux find命令中-exec參數的作用(3)

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

  實例5:查找文件移動到指定目錄

  命令:

  find 。 -name “*.log” -exec mv {} 。。 \;

  輸出:

  代碼如下:

 。踨oot@localhost test]# ll

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

  drwxrwxr-x 2 root root 4096 11-12 22:49 test3

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

 。踨oot@localhost test]# cd test3/

  [root@localhost test3]# ll

  總計 304

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

  -rw-r--r-- 1 root root 61 11-12 22:44 log2013.log

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

 。踨oot@localhost test3]# find 。 -name “*.log” -exec mv {} 。。 \;

  [root@localhost test3]# ll

  總計 0[root@localhost test3]# cd 。。

 。踨oot@localhost test]# ll

  總計 316

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

  -rw-r--r-- 1 root root 61 11-12 22:44 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 22:50 test3

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

 。踨oot@localhost test]#

  實例6:用exec選項執(zhí)行cp命令

  命令:

  find 。 -name “*.log” -exec cp {} test3 \;

  輸出:

  代碼如下:

 。踨oot@localhost test3]# ll

  總計 0[root@localhost test3]# cd 。。

 。踨oot@localhost test]# ll

  總計 316

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

  -rw-r--r-- 1 root root 61 11-12 22:44 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 22:50 test3

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

 。踨oot@localhost test]# find 。 -name “*.log” -exec cp {} test3 \;

  cp: “。/test3/log2014.log” 及 “test3/log2014.log” 為同一文件

  cp: “。/test3/log2013.log” 及 “test3/log2013.log” 為同一文件

  cp: “。/test3/log2012.log” 及 “test3/log2012.log” 為同一文件

 。踨oot@localhost test]# cd test3

 。踨oot@localhost test3]# ll

  總計 304

  -rw-r--r-- 1 root root 302108 11-12 22:54 log2012.log

  -rw-r--r-- 1 root root 61 11-12 22:54 log2013.log

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

 。踨oot@localhost test3]#

  上面就是Linux find命令中-exec參數的用法介紹了,find命令的參數還有很多,如果你還想了解其他參數的使用,詳見系統(tǒng)之家Linux find命令中-path -prune參數的作用介紹。

發(fā)表評論

0

沒有更多評論了

評論就這些咯,讓大家也知道你的獨特見解

立即評論

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

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄