Removing abnormal character DEL from a file name
Hello all
I have got certain files which somehow contain abnormal character "Del" "0x7f" or 177 which represents Del. And this is causing SVN to reject these files and abruptly end the process. I need to remove those characters from the file names but am not able to. find or grep do not search the files. This is how the file looks like with ls or find Code:
Overview_Troms?_2-thumb-144xauto-40672.jpg |
Try renaming using the inode number. You can get it using the -i switch for ls:
Code:
ls -ali Code:
192371 -rw-r--r-- 1 phaemon phaemon 0 2011-07-22 10:59 odd.file Code:
find . -inum 192371 -exec mv {} new.filename \; |
This should work as well. It removes all control characters (ascii octal 000-037,177).
Code:
file="Overview_Troms?_2-thumb-144xauto-40672.jpg" You can specify a replacement character as well. Just use "${file//[[:cntrl:]]/-}" to change them to to hyphens, for example. Edit: I just noticed what you said about having trouble searching for such files. You can use the [:cntrl:] character class in a regex or glob as well. Code:
for file in ./*[[:cntrl:]]* ; do Code:
ls *$'\177'* |
Thanks David, this is what was required.
|
All times are GMT -5. The time now is 08:35 AM. |