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 |
What is shell and terminal?
How would you print just the 25th line in a file using smallest shell script?
How to get script name inside a script?
What is the difference between a shell variable that is exported and the one that is not exported?
The information of the two files should be redirect to Third file in such a way that, the third file contain the information like this. 1st line in third file should be from 1st file 2nd line in Third file should be from 2nd file 3rd line in Third file should be from 1st file 4th line in Third file should be from 2nd file - - so on
What does chmod do?
What is shell application?
What is bash shell command?
How will you list only the empty lines in a file (using grep)?
What are different types of shell?
What is path variable bash?
What is a beat in a script?