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 does $@ mean in shell?
Create a bash shell script to sort and then uniq the file from the command line & store it to a new file and output the results to the screen. Name this script "sortAndUniq.sh"
What are the three main forms of enabling debugging in a shell script?
Explain how you Automate your application using Shell scripting.
Hi All, Is it possible to create one file name only space or space in file name in UNIX and we can able to run that on Unix?
c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory
How to group the commands in shell scripting?
madhar chod unix ke 10 commands dhang se likh nahi sakta hai
What is ms powershell?
Write a command sequence to find all the files modified in less than 2 days and print the record count of each.
What is use of "cut" command?
What is bourne shell scripting?