System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

cant delete non-existent directory in hpux

 
andypbrown
Occasional Visitor

cant delete non-existent directory in hpux

I found a directory with extraneous characters and cannot delete it via the inode method.
# ls -b gives me
\177\177\177\177\177
for a file directory name.
deleting via inode gets me
ulasap1#find . -xdev -inum 16433 -exec ll {} \;
total 0
ulasap1#find . -xdev -inum 16433 -exec rm -i {} \;
r directory
how do i delete this bogus directory?
7 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: cant delete non-existent directory in hpux

Hi:

You can't use a simple 'rm to delete a directory. You need to either (very carefully) specify 'rm -r' or use 'rmdir'.

That said, you should remember that an inode number is only unique to a file system. Thus, when using 'find()' it is advisable to restrict the search to the path in question with '-xdev'. In all, if the object that you are trying to delete is truly an empty directory, do:

# find /path -xdev -type d -exec rmdir {} +

Regards!

...JRF...
andypbrown
Occasional Visitor

Re: cant delete non-existent directory in hpux

the directory is in a subdirectory with many other files and subdirectories, so is the find /path... still the way to go?
see the output from ls -lb
drwxrwxr-x 2 dm1adm sapsys 7168 Apr 9 11:56 sapnames
-rwxr-x--- 1 root sys 20764 Mar 29 15:11 saproot.sh
drwxr-xr-x 3 eq1adm sapsys 96 Oct 22 2007 servicehttp
drwxrwxr-x 2 dm1adm sapsys 17408 Apr 9 12:22 tmp
drwxrwxrwx 3 dm1adm sapsys 96 Aug 13 2007 upgrade
-rw-rw---- 1 1076 sapsys 166877 Mar 29 09:16 zc00637i.dat
drwxr-x--- 2 dm1adm sapsys 96 Mar 29 15:19 \177\177\177\177\177

Re: cant delete non-existent directory in hpux

Do you have the DEL mapped to anything?
If not, you can simply:
cd DELDELDELDELDEL # (5 DEL keys)
Then remove any files and then "cd -" and rmdir that directory.
James R. Ferguson
Acclaimed Contributor

Re: cant delete non-existent directory in hpux

Hi (again):

It doesn't matter where the directory resides in the tree of the filesystem as long as you know the inode number and as long as you don't cross into another filesystem. I meant to write:

# find /path -xdev -type d -inum 16433 -exec rmdir {} +

You could substitute the current directory for '/path' and you could omit the '-type d' to give:

# find . -xdev -inum 16433 -exec rmdir {} +

Regards!

...JRF...

Re: cant delete non-existent directory in hpux

>so is the find /path... still the way to go?

"." is fine, unless you are in /.

>see the output from ls -lb

Adding -i would be helpful.

>JRF: when using find(1) it is advisable to restrict the search to the path in question with '-xdev'.

Andy already had that.
andypbrown
Occasional Visitor

Re: cant delete non-existent directory in hpux

the # find . -xdev -inum 16433 -exec rmdir {} +

was the successful route.

thanks very much.

James R. Ferguson
Acclaimed Contributor

Re: cant delete non-existent directory in hpux

Hi (again):

> thanks very much.

You're most welcome. I see that you are new to the ITRC Forums, so "welcome!". If the answers you received were helpful, please read:

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

Regards!

...JRF...