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 / chetan

sorry, forgot to keep the "mv" command in my last post.

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

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does $1 mean in bash?

614


c program to display the information of given file similar to givan by the unix or linux command ls -l

1695


how to get part of string variable with echo command only?

589


What are the two files of crontab command?

652


How do I read a .sh file?

529






Can you write a script to portray how set –x works?

550


What is the meaning of $1 in shell script?

592


How to debug the problems encountered in the shell script/program?

626


What is a beat in a script?

542


What is the lifespan of a variable inside a shell script?

1120


Write a shell script to get current date, time, user name and current working directory.

631


When should shell programming/scripting not be used?

590


What are the different communication commands available in the shell?

515


What happens on a system call?

558


What are scripts in psychology?

590