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 |
How can I set the default rwx permission to all users on every file which is created in the current shell?
What is the syntax of "grep" command?
How do I stop script errors?
How to pass an argument to a script?
How to sort a result of Ls -l command based on columns. Ex. i want to sort 5th column from output of ls -l command.
Dear All, Can anybody tell me how to predefind no. of selected rows from a text file.
What is the command for " how many shell is running in your system or how many shell supported by your system " ?.
Explain about echo command?
How will you find the 99th line of a file using only tail and head command?
What is bash command used for?
What are the Different types of shells?
Explore about environment variables?