我正在尝试重命名文件夹中的所有文件,用空格替换下划线。
i.e. this_is_a_test --> this is a test
Run Code Online (Sandbox Code Playgroud)
但不知何故我搞砸了引用
> for file in * ; do echo mv -v $file $(echo $file | sed 's/_/\\ /g') ; done
mv -v this_is_a_test this\ is\ a\ test
Run Code Online (Sandbox Code Playgroud)
看起来不错,但是如果我删除“回声”,mv就像删除了反斜杠一样抱怨
> for file in * ; do mv -v $file $(echo $file | sed 's/_/\\ /g') ; done
mv: target ‘test’ is not a directory
Run Code Online (Sandbox Code Playgroud)
有人可以指出我方法的错误吗?