rm files

Hi Friends,

i m in trouble..

it should be very simple but still i m helpless..

i have file name called "!"

$ ls -lrt
total 20942
drwxrwxrwx   2 user   user     29 May  8 05:48 Health21_07_05_2009_08
-rw-rw-rw-   1 user   pser   1832 May  8 05:48 08-05_processfiles.log
-rw-rw-rw-   1 user   user       503 May  8 10:14 08-05-09_101400
-rw-rw-rw- 1 user   user       824 May  8 10:23 !

my problem is that i could not rm the file here which is "!".

by mistake in vi editior i have given that name..but now i want to delete that file..

can some one help me ?

pLease note i am using SunOS 5.9

Thanks in advance
Sha

use single quote

Oops....i m afraid..

getting below error:

$ rm '!'
!: No such file or directory

Thanks
SHa

Maybe you've put in any special characters or whitespaces. Try this:

find ./* -prune -type f -exec ls -b1 {} \; | sed -e 's/^/"/' -e 's/$/"/'

Hi pludi,

i m getting below response...but still not sure how i should go ahead..
can you guid me plz..

$ find ./* -prune -type f -exec ls -b1 {} \; | sed -e 's/^/"/' -e 's/$/"/'
"./08-05-09_030102_processfiles.log"
"./08-05-09_101400_processfiles.log"
"./1\177!"

Thanks
Sha

Seems like you first typed a '1', then hit del, seemingly erasing the character, and then '!<Return>'
Try this:

find ./* -prune -type f -name '1?!' -ok rm {} \;

It will ask for confirmation before it deletes anything, just to be on the safe side.

Thanks a lot Pludi..
:slight_smile:

Great it worked..

Thanks all again
Sha

if file name is only '!', you can remove it by " rm !"
but i feel its not the case.
its all files using "ls -b" it will print non printable characters also in ascii format,

use man ascii to see character belong to that value.

then use rm command to remove it "rm !(ctrl V + that key)

eg : # ls -lbA shows me
-rw-r--r-- 1 root other 0 Mar 7 14:55 !\177 ( ! + delet key)

rm !(CTRL-V) (press delete key)
will appear as
rm !^?

credit goes to some one else :slight_smile:

try using bash shell

THanks for the info anup

Thanks
Sha