Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.

Answers were Sorted based on User's Feedback



How do you rename the files(*.sh) with file names containing space in it?for example "interview..

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

How do you rename the files(*.sh) with file names containing space in it?for example "interview..

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

How do you rename the files(*.sh) with file names containing space in it?for example "interview..

Answer / abc

For single file, you can do following command;

mv "interview question.sh" interview-question.sh

Is This Answer Correct ?    4 Yes 0 No

How do you rename the files(*.sh) with file names containing space in it?for example "interview..

Answer / indusharma5

I tried following, but it doesn't work.
find . -name "*.sh" -0 -print0| xargs -n1 -I{} -0 sh -c '`mv {} echo "{}"|sed -n 's/ /-/g'`'

Is This Answer Correct ?    2 Yes 0 No

How do you rename the files(*.sh) with file names containing space in it?for example "interview..

Answer / chetan

for i in *.sh
do
echo $i|sed 's/ /-/g'
done

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Shell Script Interview Questions

what is the difference between writing code in shell and editor?

1 Answers  


How to print all the arguments provided to the script?

0 Answers  


Write a script to print the first 10 elements of fibonacci series.

0 Answers  


What is the difference between bash and shell?

0 Answers  


Why is a script important?

0 Answers  


What are scripts in psychology?

0 Answers  


Explain how you Automate your application using Shell scripting.

0 Answers   MAHINDRA,


How do you find out What is your shell?

0 Answers  


What is the syntax of "grep" command?

4 Answers  


What is the default ubuntu terminal?

0 Answers  


What are the three main forms of enabling debugging in a shell script?

6 Answers   ADC, Wipro,


How do I debug a shell script?

0 Answers  


Categories