我正在尝试重新编码目录中的所有文件并将结果放入子目录中。 我正在使用
find . -type f -name '*.txt' -execdir iconv -f utf-16 -t utf-8 {} > reencoded/{} \;
但是文件名不会替换第二次出现的“{}”,而是会在 reencoded/{} 中出现结果。
最佳答案
将该命令包含在对 sh -c
的调用中,然后可以将 {}
引用为 $0
:
find . -type f -name '*.txt' -execdir sh -c 'iconv -f utf-16 -t utf-8 "$0" > reencoded/"$0"' {} \;
关于Linux find重新编码所有文件到子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31145024/