1831628 Members
3056 Online
110027 Solutions
New Discussion

Re: Remove file

 
SOLVED
Go to solution
juno2
Super Advisor

Remove file

there are some strange files in our system , it can't be delete or move by "rm" or "mv" , but it can list by "ll" , how can I delete the file? thx.
4 REPLIES 4
Stuart Browne
Honored Contributor
Solution

Re: Remove file

Start by getting their proper names.

The 'ls' command has a flag '-b' which will show all non printable characters in octal mode. Once you've figured out what their real name is, you can then do some creative things with 'rm' and 'echo' to remove them, for instance:

rm -i `echo -e "funky\033file"`

Failing that, you could always just use 'rm -i' with the appropraite wildcard mask ('rm -i' of course being remove interactivly (say Y/N)).
One long-haired git at your service...
Steven E. Protter
Exalted Contributor

Re: Remove file

You could also use the tab key for name completion, so long as the funny characters aren't at the beginning of the name.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Umapathy S
Honored Contributor

Re: Remove file

my way is
ls >tmp.out

now you can see any unprintable char in your file names. Remove the rest and add rm before the filenames and execute the tmp.out.

Its done.

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
John Poff
Honored Contributor

Re: Remove file

Hi,

Here is one method I have used to remove files with bad filenames. Use the '-i' option on the ls command to get the inode number of the file, and then use the '-inum' option in find to rm the file:

$ ls -li oo*.txt
442825 -rw-r--r-- 1 jpoff users 1102 Sep 12 2002 oops.txt

$ find -inum 442825 -exec rm {} \;

JP