Linux - 替换文件名中的空格

我在一个文件夹中有许多文件,我想用下划线替换所有文件名中的每个空格字符。我怎样才能做到这一点?

最佳答案

应该这样做:

for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done

https://stackoverflow.com/questions/1806868/

相关文章:

linux - 安装 Jenkins 后无法 su 到用户 jenkins

python - 在类方法上使用 property()

linux - 错误 : Can't open display: (null) when using

python - 在pytest中,conftest.py文件有什么用?

python - 是否可以将已编译的 .pyc 文件反编译为 .py 文件?

c - 如何设置 cron 作业以每小时运行一次可执行文件?

python - 为什么 (1 in [1,0] == True) 评估为 False?

python - 定义Python源代码编码的正确方法

linux - 如何从文本文件中删除换行符?

linux - 并排显示两个文件