前些天,我要把Linux上的幾千個txt檔案進行轉碼,需要用到iconv命令,可是我總不能 一個一個的去敲,
檔案轉碼命令:iconv -f GBK -t UTF-8 file1 -o file2
將file1從GBK轉為UTF-8,并輸出為file2,
于是我發現了find命令的一個exec引數,
[root@iZrzyv77duj240Z ~]# ls /mnt/
test.txt
[root@iZrzyv77duj240Z ~]# find /mnt -type f -exec ls -l {} \;
-rw-r--r-- 1 root root 6691 Sep 27 14:20 /mnt/test.txt
在/mnt下搜索,型別為檔案,{}表示find的搜索結果,
固定格式為:“find 路徑 -exec 命令 {} \;”
意思是查找/mnt下的所有檔案,并對每個檔案執行ls -l命令,
所以我的操作命令是:
[root@iZrzyv77duj240Z ~]# find /txt/ -type f -exec iconv -f gbk -t utf8 {} -o {} \;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/135993.html
標籤:AI
