Linux 找到将所有文件重新编码到子目录

Linux find reencode all files to subdirectory

我正在尝试重新编码目录中的所有文件并将结果放在子目录中。 我正在使用

find . -type f -name '*.txt' -execdir iconv -f utf-16 -t utf-8 {} >  reencoded/{} \;

但是文件名并没有替换第二次出现的'{}',而是在reencoded/{}中有一个结果。

将命令包装在对 sh -c 的调用中,然后可以将 {} 引用为 [=13=]:

find . -type f -name '*.txt' -execdir sh -c 'iconv -f utf-16 -t utf-8 "[=10=]" >  reencoded/"[=10=]"' {} \;