1834513 Members
2130 Online
110068 Solutions
New Discussion

Cannot delete a file

 
MTSU_SAN
Regular Advisor

Cannot delete a file

I have a directory, with a file in it that I cannot pattern match--the octal characters show this:
frank:[/users/student2/0006/deleted] # ls -b
.addressb\033on\215lu .pine-de'Mg3

but no rm .a* or any rm .* will catch it:
frank:[/users/lu non-existenteleted] # rm .a*
You see how it wrote over the current line with the lu? Any ideas? I even tried deleting the inode, and that won't work either:
frank:[/users/student2/0006/deleted] # find . -inum 49196 -exec rm {} \;
It is still there afterwards, with no errors or messages. I would really like to clean this up, it is bugging me!
Thanks for any ideas,
c*
20 REPLIES 20
Pedro Cirne
Esteemed Contributor

Re: Cannot delete a file

Hi,

Try rm -i * and answer yes only on the file you want to remove.

Enjoy :-)
DCE
Honored Contributor

Re: Cannot delete a file

Have you tried using the GUI version of SAM? Under Routine tasks selection you can display a list of files, highlight the one you are interested in, and delete it.

Hope this is of some help

Dave
Mel Burslan
Honored Contributor

Re: Cannot delete a file

a little bit convoluted way of accomplishing this would be:


cd /users/student2/0006/deleted
mkdir /tmp/tempstorage
cp -Rp * /tmp/tempstorage
cd ..
rm -r /users/student2/0006/deleted
mkdir /users/student2/0006/deleted
(modify ownership and permissions properly here)
mv /tmp/tempstorage/* /users/student2/0006/deleted

with the same regex matching logic, files with offending characters will not match * and will not be copied to /tmp/tempstorage, hence when you remove the whole directory, they will be gone. After that you will restore the salvaged files back to the original location.

I am not sure why a* is not matching this file, but obviously, one or more of these offending characters do something like cursor location manipulation, causing you this much headache.

Hope this helps..
________________________________
UNIX because I majored in cryptology...
Devesh Pant_1
Esteemed Contributor

Re: Cannot delete a file

I have had success with the rm -i * command in the past.
One more trick that I use is

rm .a

Where is the escape key
Hit the escape key twice and that will auto complete the command and will automatically find the name with hidden/non ascii characters and complete the word.

tanks
Devesh
Sandman!
Honored Contributor

Re: Cannot delete a file

Jerry,

I tried deleting the file using its inode number and it worked fine. Here's what I did on my system:

1. ls -i ".addressb\033on\215lu .pine-de'Mg3"
2. find . -inum -exec rm {} \;
3. repeat step 1 to verify it got deleted

cheers!
MTSU_SAN
Regular Advisor

Re: Cannot delete a file

Thanks for all of your suggestions! Except for the sam one, I had already tried all of them, and they did not work! I thought I knew so much!
I will try sam, and also emacs (which allows a directory listing inside)--I wish I had thought of that before.
c*
MTSU_SAN
Regular Advisor

Re: Cannot delete a file

Nope, neither sam or emacs could do it either--those octal characters are cursor manipulators, and so interfere with the deletion. Any other suggestions?
c*
Rodney Hills
Honored Contributor

Re: Cannot delete a file

Could it be possible the file is on a NFS mount and you don't have permission to delete it?

Try-
rm .a* >/tmp/msg 2>&1
strings /tmp/msg

And see if any message you can't see on the screen is being displayed...

HTH

-- Rod Hills
There be dragons...
MTSU_SAN
Regular Advisor

Re: Cannot delete a file

Thanks, this was a novel idea, but it is just saying:
frank:[/users/student2/0006/deleted] # rm .a* > /tmp/msg 2>&1
frank:[/users/student2/0006/deleted] # more /tmp/msg
rm: .addressb^[onM-^Mlu non-existent


which is what I get on the command line (but it is hard to tell since it is written over).
c*
Mel Burslan
Honored Contributor

Re: Cannot delete a file

just a wild suggestion:

set your term to "unknown" rather than hp or vt100 or whatever else. then try doing cat on /tmp/msg to see what characters are there.

then try constructing the file name using the esc sequences from the command line of your "unknown" terminal using ctrl-V then the ctrl-character sequences and delete it.

Again this is just a wild suggestion and it still at the end, your regex matching should not be dependent on what type of terminal you are using when you run an rm .a* command.
________________________________
UNIX because I majored in cryptology...
Sandman!
Honored Contributor

Re: Cannot delete a file

please post the output of the ll command in the dir where the file exists

thanks
TwoProc
Honored Contributor

Re: Cannot delete a file

run your ls with an octal dump to see the characters hidden in there.

ls -1 | od -c

With that you'll get a better idea of what you're dealing with.

But, the Mel's posting where everything else gets moved out, and then your whole directory gets removed should work for you.

Another trick...

rm -i ./* ./.*

or...

cd ..
rm -i ./deleted/* ./deleted/.*

Then answer yes for the file you want gone.

This is similiar to one of the previous posting, except that you're prefixing a directory in there.

We are the people our parents warned us about --Jimmy Buffett
Rodney Hills
Honored Contributor

Re: Cannot delete a file

Don't use the "more" command. Use the "strings" command to display the non-binary data...

-- Rod Hills
There be dragons...
Eknath
Trusted Contributor

Re: Cannot delete a file

Hi Jerry,

Try this
#mv ".address " 1234 (hitescape key twice)
#rm 1234

Hope this works.

Cheers!!!
eknath
CAS_2
Valued Contributor

Re: Cannot delete a file

As John Joubert suggest, I'd type:

ls -1 | xd -tx1 -tc

in order to get the characters of that filename.

Please, run that command line and post its output here.
Muthukumar_5
Honored Contributor

Re: Cannot delete a file

You can try as,


cd /users/student2/0006/
mkdir deleted_new
cp -ri deleted/* deleted_new

Press n for that specific file and move this new as old one.

rm -f ./.address*

hth.
Easy to suggest when don't know about the problem!
MTSU_SAN
Regular Advisor

Re: Cannot delete a file

-rw-r--r-- 1 root sys 33 Jun 16 15:50 /tmp/msg
frank:[/] # strings /tmp/msg
rm: .addressb
lu non-existent
frank:[/] # cd /users/student2/0006/deleted
frank:[/userlu not found006/deleted] # ll
./.pine-de'Mg3 not found
total 0
frank:[/userlu not found006/deleted] # ls -l | od -c
./.pine-de'Mg3 not found
0000000 t o t a l 0 \n
0000010
frank:[/userlu not found006/deleted] # ls -l | xd -tx1 -tc
./.pine-de'Mg3 not found
0000000 74 6f 74 61 6c 20 30 a
t o t a l 0 \n
0000008

There are answers to all the requests for posts, still nothing works. There is only that one file in the directory, and rm -r of the directory won't work, so moving everything else out is moot. Do these outputs give anyone ideas?
c*
Fred Ruffet
Honored Contributor

Re: Cannot delete a file

What about using perl and its wonderful unlink command ? store filename in a variable en unlink it.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Rodney Hills
Honored Contributor

Re: Cannot delete a file

I would guess the directory the file is in is corrupted. umount the filesystem the directory is in and run fsck.

-- Rod Hills
There be dragons...
MTSU_SAN
Regular Advisor

Re: Cannot delete a file

Nope, already tried fsck, too.
I'm working on the programming end of it (perl).
c*