熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動盤 真正純凈版的win7系統(tǒng)
時間: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/
。踨oot@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 {} 。。 \;
。踨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
[root@localhost test]#
實例6:用exec選項執(zhí)行cp命令
命令:
find 。 -name “*.log” -exec cp {} test3 \;
輸出:
代碼如下:
[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]# 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
[root@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參數(shù)的用法介紹了,find命令的參數(shù)還有很多,如果你還想了解其他參數(shù)的使用,詳見系統(tǒng)之家Linux find命令中-path -prune參數(shù)的作用介紹。
發(fā)表評論
共0條
評論就這些咯,讓大家也知道你的獨特見解
立即評論以上留言僅代表用戶個人觀點,不代表系統(tǒng)之家立場