1752777 Members
6120 Online
108789 Solutions
New Discussion юеВ

How to remove weird file

 
SOLVED
Go to solution
Tonya Underwood
Regular Advisor

How to remove weird file

camintp6:/home/egprdbb/bin # ll | more
total 454
drwx------ 3 root sys 96 Mar 2 15:24 ^V


When I do an ll (without more)

camintp6:/home/egprdbb/bin # ll
total 454
drwx------ 3 root sys 96 Mar 2 15:24


How can I remove this directory?

Thanks!
10 REPLIES 10
Hein van den Heuvel
Honored Contributor

Re: How to remove weird file

Just use rm -R -i (or rmdir -i)

hth,
Hein
Bob E Campbell
Honored Contributor

Re: How to remove weird file

Always fun to create unprintable file and directory names. Assuming that the directory is empty you should be able to use:

rmdir \cntrl-V

Just type a backslash '\' character that tells the shell to ignore any special properties of the next character. Then hold down the ctrl button and press V.

Good luck!
Pete Randall
Outstanding Contributor

Re: How to remove weird file

One of the easiest ways is to use "rmdir -i *", then respond "n" to all those you want to keep.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: How to remove weird file

You have control characters embedded in the filename.

Do this but be careful:

cd to parent directory.
rmdir -i *

You will be prompted for each file/directory name. Answer 'y' ONLY to the directory that you want to delete. Answer 'n' to everything else. After your directory has been deleted, you can enter Ctrl-C (or whatever your intr character is set to) to terminate the command.

If the direcory is not empty then you need to do a
rm -r -i *
which will also ask before removing.


If it ain't broke, I can fix that.
Tonya Underwood
Regular Advisor

Re: How to remove weird file

I had already tried the \cntlv but that did not work...

I did an rmdir -i * and did it that way. Should've thought of that.

THANKS
Tonya
Tonya Underwood
Regular Advisor

Re: How to remove weird file

camintp6:/home/egprdbb/bin # rm -i -r *
directory : ? (y/n) y
directory /home: ? (y/n) camintp6:/home/egprdbb/bin # ll | more
total 454
drwx------ 3 root sys 96 Mar 2 15:24 ^V


Wait! It did not work. Still there. Then it lists a dir (/home) that is not even in this directory... ??? Confused!
Bob E Campbell
Honored Contributor

Re: How to remove weird file

Curious. I retried \ctrl-V and it worked most of the time, but sometimes it ended up as a ^J. I love it when computers are random, will look into this in my copious free time (if nobody has that answer)

Answered my own question but still do not understand. Using:

rmdir \^V^V

ended up as a single ^V. I wonder if that was due to the shell editor....
James R. Ferguson
Acclaimed Contributor
Solution

Re: How to remove weird file

Hi:

Yet another way is to find the inode number of the directory and remove by that:

# ls -il
340 drwx------ 3 root sys 96 Mar 2 15:24 ^V

...the inode number is 340. Now:

# cd /path
# find /path -xdev -type d -inum 340 -exec rm -ri {} \;

Note that inode numbers are only unique within a filesystem.

Regards!

...JRF...
Tonya Underwood
Regular Advisor

Re: How to remove weird file

the find by inum was perfect. Thanks.
Done.