In this post we will learn, how we can convert hyphen to underscore in between of all filenames with the help of shell script or bash script.
For eg. if you want to convert the file haveing hyphen sign in between its name to Underscore .
Use the below given method.
After using the script the file will be named like this ;
Before using script: file-name
After using script: file_name
Create a file ,paste the below given contents and make it executable by “chmod +x filename” command.
#!/bin/bash # Example of converting - to _ in all files in current directory where this script is. for i in `ls *-*` do NEW=`echo $i|tr '-' '_'` mv $i $NEW done