Linux - Replacing spaces in the file names

前端 未结 11 673
臣服心动
臣服心动 2021-01-29 18:21

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?

11条回答
  •  暖寄归人
    2021-01-29 18:53

    The easiest way to replace a string (space character in your case) with another string in Linux is using sed. You can do it as follows

    sed -i 's/\s/_/g' *
    

    Hope this helps.

提交回复
热议问题