I tried to remove apostrophe from all files' names in the directory.
for i in *; do mv $i `echo $i | tr -d "'"`; done
After executing this command nothing is renamed.
Do you know what's wrong here?
|
I tried to remove apostrophe from all files' names in the directory.
After executing this command nothing is renamed. Do you know what's wrong here? |
|||||
|
|
You could try something like this (
This uses shell string replacement. You probably don't want to glob files that don't have |
|||
|
|
|
Always put double quotes around variable substitutions
This will mostly work, with a few restrictions:
In ksh93, bash and zsh, you can write this with less hassle using the
In zsh, you can use
Under Debian, Ubuntu and other derivatives, you can use the
|
|||
|
|
|
I assume your problem is the file also had spaces in its name. I can't reproduce your error without it.
So the reason it's failing is the second message: When your for loop sees a file with a space, it runs this:
So it thinks you're specifying three files ( Proper quoting of both should solve your immediate problem
|
||||