How do you rename the files(*.sh) with file names containing space in it?for example "interview question.sh" needs to rename to "interview-question.sh".
Appreciate your inputs.Thanks.

Answer Posted / senthil m

For single file, you can do following command;

mv interview\ question.sh interview-question.sh

For multiple files on the current working folder;

for i in *\ *.sh
do
j=`echo $i|sed "s/ /-/g"`
mv "$i" $j
done

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens when you type ls?

770


What is a boot block?

784


Explain about return code?

854


Why are shell scripts used?

848


How to print all the arguments provided to the script?

791


What is awk in shell scripting?

823


How can we find the process name from its process id?

932


How do I edit a .sh file?

890


Is shell scripting easy to learn?

790


What is web script?

819


Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?

1950


What is .sh file in mac?

791


What is sudo command?

782


is this growing field and what is average package in this?

2106


Is scripting and coding the same thing?

776