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

Calculate a real number calculation directly from the terminal and not any shell script.

917


How will you find the 99th line of a file using only tail and head command?

2288


Can shell script run on windows?

772


Is bash a shell script?

814


How do I read a .sh file?

764


How to check if a directory exists?

797


Is powershell a language?

774


What does egrep mean?

747


What is mac default shell?

815


What is a file basename?

795


What is path in shell script?

822


determine the output of the following command: echo ${new:-variable}

757


Why is the use of shell script?

755


What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?

803


What is the difference between break and continue commands?

799