[英]Linux find reencode all files to subdirectory
I'm trying to reencode all files in a directory and put the results in a subdirectory.我正在尝试重新编码目录中的所有文件并将结果放在子目录中。 I'm using
我正在使用
find . -type f -name '*.txt' -execdir iconv -f utf-16 -t utf-8 {} > reencoded/{} \;
But the filename does not replace the second occurrence of '{}', there is a result in reencoded/{} instead.但文件名不会替换第二次出现的“{}”,而是在重新编码/{} 中产生结果。
将命令包装在对sh -c
的调用中,然后可以将{}
引用为$0
:
find . -type f -name '*.txt' -execdir sh -c 'iconv -f utf-16 -t utf-8 "$0" > reencoded/"$0"' {} \;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.