Linux - 替换文件名中的空格 [英] Linux - Replacing spaces in the file names

查看:33
本文介绍了Linux - 替换文件名中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this?

推荐答案

应该这样做:

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

这篇关于Linux - 替换文件名中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆