Operating System - HP-UX
1833788 Members
2506 Online
110063 Solutions
New Discussion

Deleting a directory with no name

 
SOLVED
Go to solution
Jim Mulshine
Frequent Advisor

Deleting a directory with no name

Does anyone know of a way to delete a directory that has no (visible) name? See what I mean...
# cd /
# ll | head -2
total 256
drwxrwxrwx 2 root sys 8192 Oct 27 09:28
#
13 REPLIES 13
Pete Randall
Outstanding Contributor
Solution

Re: Deleting a directory with no name

Jim,

You can *VERY CAREFULLY* do an "rm -rfi *" and respond no to everything but the blank directory.


Pete



Pete
A. Clay Stephenson
Acclaimed Contributor

Re: Deleting a directory with no name

First, do an ls -b to display the non-printable characters in octal. That may give you a way to create a wildcard pattern for the rm command. Plan B. Do a rm -i * and answer 'n' (No) for the files displayed until you get to the mystery file. Answer 'y' (yes) for that one and then you can enter Cntl-C for the next file prompt to terminate the rm command. Man rm first and be vewry, vewry careful.
If it ain't broke, I can fix that.
harry d brown jr
Honored Contributor

Re: Deleting a directory with no name

do a "ll | head -2 | od -bc".

I created a directory CTRL-A and it shows up like this:

# ll | head -2 | od -bc
0000000 t o t a l 2 5 8 0 \n d r w x r
164 157 164 141 154 040 062 065 070 060 012 144 162 167 170 162
0000020 w x r w x 2 r o o t
167 170 162 167 170 040 040 040 062 040 162 157 157 164 040 040
0000040 s y s
040 040 040 040 040 163 171 163 040 040 040 040 040 040 040 040
0000060 9 6 N o v 4 1
040 040 040 040 040 071 066 040 116 157 166 040 040 064 040 061
0000100 0 : 3 6 001 \n
060 072 063 066 040 001 012
0000107
#

Note the 001 on the last line, that's a ctrl-A.

rm -ri *

CAREFUL though, it's saying to remove files and directories, but PROMPT first. The CTRL-A directory prompted me TWICE to delete it:

# rm -ir *
directory : ? (y/n) y
: ? (y/n) y
OLDsulog: ? (y/n) q

At the OLDsulog file I CTRL-C'd out of rm

live free or die
harry
Live Free or Die
Jeff Schussele
Honored Contributor

Re: Deleting a directory with no name

Hi Jim,

Do an
rmdir -i *.*
And make sure you reply NO to everything BUT this entry.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Pramod_4
Trusted Contributor

Re: Deleting a directory with no name

You can do "rmdir -i *" and type yes when you get prompted like the following:
: ? (y/n)

Thanks,
Pramod
Robert-Jan Goossens
Honored Contributor

Re: Deleting a directory with no name

Jim,

# ls -i /dir
find the inode number in the above command

# find /dir -inum xxxx -xdev -exec rmdir {} \;

Robert-Jan.
Kevin Wright
Honored Contributor

Re: Deleting a directory with no name

ls -li should give you the inode. find /dir -inum <#> |xargs rm.
A. Clay Stephenson
Acclaimed Contributor

Re: Deleting a directory with no name

Oops, I meant rmdir -i * rather than rm -i * but the same applies and do the ls -b first.
If it ain't broke, I can fix that.
Leif Halvarsson_2
Honored Contributor

Re: Deleting a directory with no name

Hi,
Do you run CDE ? Try to change the name from the file manager (dtfile).
Umapathy S
Honored Contributor

Re: Deleting a directory with no name

Another way is
ls >/tmp/tmp.out

open tmp.out and see the files. Remove all the entries you want to keep and leave out only those to delete.

add rm infront with awk and run that as a script.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Mark Greene_1
Honored Contributor

Re: Deleting a directory with no name

an ls -l |cat -v will show the control character in a format that you can duplicate on the keyboard.

For example, I did a mkdir and enterd a control-T. I can display it like this:

ls -l |cat -v
total 0
drwxrwxrwx 2 mgreene general 96 Nov 4 10:47 ^T

and now I an use rmdir to remove it by entering a control-V then a control-T and pressing enter.

mark
the future will be a lot like now, only later
curt larson_1
Honored Contributor

Re: Deleting a directory with no name

first you can try to make the name visible

ll -i | head -2 | vis
i'd see just how many invisible names there are first.
then you can use wildcards
rmdir -i *

or use find

find . -inum numberFromUsingll-i -exec rmdir {} \;

of course by using rmdir, the directory has to be empty
Jim Mulshine
Frequent Advisor

Re: Deleting a directory with no name

Thank you everyone for your (very) fast responses to my question...problem solved! /Jim