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
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 |
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 |
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 |
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 |
Explore about environment variables?
What are the different kinds of loops available in shell script?
how to search for vowels a,e,i,o,u appearing in the same sequence in a file
Write a command sequence to find all the files modified in less than 2 days and print the record count of each.
What is the use of break command?
What is the difference between grep and egrep?
How to print all array elements and their respective indexes?
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 ?
What is shell and shell script?
Explain about debugging?
I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?
How will I insert a line "abcdef" at every 100th line of a file?