Bash: mv: 指定的目标不是目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8756554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:15:16  来源:igfitidea点击:

Bash: mv: target specified is not a directory

linuxbashmv

提问by Crazy_Bash

For some reason mv doesn't work properly in my bash script. This script should rename mp3 files with spaces

出于某种原因, mv 在我的 bash 脚本中无法正常工作。此脚本应使用空格重命名 mp3 文件

ls *mp3 > ls2.txt

while read line
do
        sed_name=$(echo $line | sed 's/ /_/g' | sed "s/'//g")
        mv  "'"$line"'" "'"$sed_name"'";
done < ls2.txt

rm ls2.txt

but I'm getting the following error mv: target specified is not a directory (mv: указанная цель не является каталогом)

但我收到以下错误 mv: target specified is not a directory (mv: указанная цель не является каталогом)

回答by synthesizerpatel

Instead of "'"$line"'".. just try

而不是 "'"$line"'" .. 试试

mv "$line" "$sed_name"

mv "$line" "$sed_name"