小编MrJ*_*s87的帖子

bash:用空格移动文件

当我移动文件名中带有空格的单个文件时,它的工作方式如下:

$ mv "file with spaces.txt" "new_place/file with spaces.txt"
Run Code Online (Sandbox Code Playgroud)

现在我有一个可能包含空格的文件列表,我想移动它们。例如:

$ echo "file with spaces.txt" > file_list.txt
$ for file in $(cat file_list.txt); do mv "$file" "new_place/$file"; done;

mv: cannot stat 'file': No such file or directory
mv: cannot stat 'with': No such file or directory
mv: cannot stat 'spaces.txt': No such file or directory
Run Code Online (Sandbox Code Playgroud)

为什么第一个示例有效,而第二个示例无效?我怎样才能让它工作?

bash files mv

13
推荐指数
2
解决办法
1万
查看次数

标签 统计

bash ×1

files ×1

mv ×1