我有一个目录,其中包含多个文件,文件名中带有空格。我想在名称中找到一个模式,这些文件将被移至其他目录。现在的问题是,当在单个文件名中找到特定模式时,该文件将移动到目标路径,但是当有多个文件时,此方法将失败。以下是我正在使用的代码:
for file in `find . -maxdepth 1 -name "*$pattern*xlsx" -type f`
do
mv "$file" $destination/
done
最佳答案
无需使用循环:
find . -maxdepth 1 -name "*$pattern*xlsx" -type f -exec mv {} $destination +
关于linux - move 多个名称中包含空格的文件(Linux),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20781936/