![重命名多个不带扩展名的文件?](https://linux22.com/image/47346/%E9%87%8D%E5%91%BD%E5%90%8D%E5%A4%9A%E4%B8%AA%E4%B8%8D%E5%B8%A6%E6%89%A9%E5%B1%95%E5%90%8D%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%9F%20.png)
我有多个文件,全部命名为
seperate1
seperate2
等等。我如何重命名它们以具有扩展名.csv
?
答案1
如果只有需要重命名的文件:
for file in *; do
mv "$file" "${file}.csv"
done
如果存在必须排除的带有点的文件:
for file in *; do
[[ $file == *.* ]] && continue
mv "$file" "${file}.csv"
done
或者与shopt -s extglob
:
for file in +([^.]); do
mv "$file" "${file}.csv"
done