任何人都可以推荐一个安全的解决方案,从给定的根目录开始递归地用文件和目录名称中的下划线替换空格?例如:
$ tree
.
|-- a dir
| `-- file with spaces.txt
`-- b dir
|-- another file with spaces.txt
`-- yet another file with spaces.pdf
Run Code Online (Sandbox Code Playgroud)
变为:
$ tree
.
|-- a_dir
| `-- file_with_spaces.txt
`-- b_dir
|-- another_file_with_spaces.txt
`-- yet_another_file_with_spaces.pdf
Run Code Online (Sandbox Code Playgroud)