Operating System - HP-UX
1753366 Members
5877 Online
108792 Solutions
New Discussion юеВ

Re: Remove a directory with no name

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Remove a directory with no name

Hi,

Our developers ran a script on the weekend which they created in windows...somehow it got screwed up (I imagine with a ^M somewhere) and they created a directory with 1GB of files in it but the directory has no name. How can I remove it?

root:/data# ll
total 60546
drwxr-xr-x 2 usrx1 ind 666624 Sep 16 12:39
-rw-r--r-- 1 user2 dba 26421 Sep 8 06:02 03964402.dfc
-rw-r--r-- 1 root sys 9563647 Sep 12 09:57 11Sep07_dat.zip
-rw-r--r-- 1 root sys 19880461 Sep 12 09:57 11Sep07_tif.zip
-rw-r--r-- 1 usrx1 ind 0 Sep 15 23:46 NULL

See how there is no name for the very first entry?
8 REPLIES 8
Oviwan
Honored Contributor

Re: Remove a directory with no name

Hey

I assume that ^M are two spaces.

so try this with two spaces:

$rmdir -- " "

Regards
Pete Randall
Outstanding Contributor

Re: Remove a directory with no name

How about something like this:

find /start_dir -type d -exec rm -rfi {} ;\

Then reply n to any legitimate directories and y to this bogus one.


Pete

Pete
James R. Ferguson
Acclaimed Contributor
Solution

Re: Remove a directory with no name

Hi:

Find the inode of the directory and use that to remove it:

# ls -il

Using the inode number :

# find /path -xdev -inum -type d -exec rm -ir {} \;

Regards!

...JRF...
Tom Danzig
Honored Contributor

Re: Remove a directory with no name

You can do an 'ls -l' on the directory the dir is in and output to a file. Then vi the file. This will show the actual charactures in the dir name.

Also, if there are not too many files in the directory it's in, you can do "rm -ri *" and answer no to all but the offendict dir.

Tom Danzig
Honored Contributor

Re: Remove a directory with no name

You can do an 'ls -l' on the directory the dir is in and output to a file. Then vi the file. This will show the actual charactures in the dir name.

Also, if there are not too many files in the directory it's in, you can do "rm -ri *" and answer no to all but the offending dir.

Coolmar
Esteemed Contributor

Re: Remove a directory with no name

Tom...

When I outputted ls -l to a file, here is what it gave...what I suspected in my above post:

total 60546
drwxr-xr-x 2 indusrx1 ind 666624 Sep 17 10:03 ^M

I would prefer to blow away the whole directory without being prompted for each file because there are hundreds of files.
Coolmar
Esteemed Contributor

Re: Remove a directory with no name

I used James' approach but changed the rm -ir to "rm -R" as there were way to many files for me to answer y/n to each one.

Thanks everyone who replied.
Dennis Handly
Acclaimed Contributor

Re: Remove a directory with no name

If you use ll -b, you can see the name of the directory. If you rename the directory, then you can use the normal commands to delete the contents.

You could also move all of the good files out of the directory that contains the bad name, then rename that directory, and put the good files back. Then remove the directory with the bad file.

If the name actually had a CR, you can write a script using vi and control-V and CR and then remove only that directory.