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 |
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 inside a seashell?
How does ls command work?
c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again
How to get script name inside a script?
What is the use of "$?" Sign in shell script?
write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?
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
write a scwipt that a) takes exactly one argument, a directory name. b) if the number of argument is more or less than one,print a usage message c) if the argument is not adirectory, print another message d) for the given directory, print the five biggest files and the five files that were most recently modified. e) save the output to a file called q2output.
How to check if a directory exists?
In shell scripting if text is surrounded by single quotes what does it denotes?
What is the use of .sh file?