[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How do I remove a bad file??



On 20120501_204601, John L. Cunningham wrote:
> 
> On Tue, May 01, 2012 at 06:20:11PM -0500, Dennis Wicks wrote:
> > Greetings;
> > 
> > I have a file that looks like the following in an ls list;
> > 
> > -????????? ? ?    ?             ?                ? Inbox.msf
> > 
> > I can't do anything with it. Can't mv, rm, cp, or anything else I
> > have thought of to get rid of it or write over it.
> > 
> > Any ideas how I can get this thing out of my life??
> 
> If there is no GUI available, this trick using find and the file's inode number will work:
> 
> http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html
> 

To OP:

Use find to do the whole job:
1. cd into the directory in which the file with the bad name is lodged,
2. find . -maxdepth 1 -ls
3. look at output and add restrictions to the search criteria of find, 
4. repeat 2. until the bad file is the only one found. Then go to 5.
5. add -delete to the end of the find command that was developed by the 
   above, and run it.

You might want to skim the find man page to see what -maxdepth does.
I would add a test that the file name not have an initial letter that
is the same as the initial letter of any good file in the directory.

! -name '[a-zA-Z0-9]*' 

This should make pretty much everything but your bad file drop out of
the find output. If not tweak the find command some more, but don't
add the -delete until the bad file is the only one present in the trial
runs. Don't assume that you know the regular expression rules. Find has
its own regex rules. They are similar to other regex, but for cleanup
work like this, the game of not adding the delete until you are sure
the the whole of the command is right is a strategy that will save you
from a lot of grief.  

But if you don't have .history working in your xterm, all of this is
largely worthless. Don't try it with the find command and changes to
it are recorded with pencil on a note pad!!! 

-- 
Paul E Condon           
pecondon@mesanetworks.net


Reply to: