当我移动文件名中带有空格的单个文件时,它的工作方式如下:
$ 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)
为什么第一个示例有效,而第二个示例无效?我怎样才能让它工作?