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

Directory removal on HP-UX Systems

 
sksonkar
Contributor

Directory removal on HP-UX Systems

Hi,

 

I need some more clarification on directory removal.

 

1) If a file system is mounted on  mount point /opt/red/blue.

what will happen If i issue $rm  -rf /opt/red/blue/*

 

2) If a file system is mounted on mount point /opt/red/blue/ and there are couple of directories created underneath it

Like  /opt/red/blue/dir1/dir2.

 

(i) If i issue rm -rf /opt/red/blue/dir1/*

 

(ii) If i issue rm -rf /opt/red/*

 

I don't have access to HP-UX test server and don't want to try any destructive commands on live production servers.

 

Thanks,

Shiv

 

2 REPLIES
Matti_Kurkela
Honored Contributor

Re: Directory removal on HP-UX Systems

1.)

All the files and sub-directories (and their sub-directories...) in /opt/red/blue will be deleted.

 

Exception: if there are hidden files/directories (=files/directories with "." as the first character of their filenames) in /opt/red/blue, they will not be deleted. Hidden files/directories in non-hidden sub-directories of /opt/red/blue will all be deleted. This is because the * wildcard will match only non-hidden files and directories, but the "-r" option will cause everything in matched files and directories to be deleted.

 

2.)

i) All the files and sub-directories in /opt/red/blue/dir1 will be deleted, including /opt/red/blue/dir1/dir2 and everything inside it. (with a similar exception as in case 1)

 

ii) All the files and and sub-directories in /opt/red will be deleted, except /opt/red/blue because it cannot be deleted before unmounting the filesystem (and you will get an error message about not being able to delete the mount point). However, the contents of /opt/red/blue will all be deleted: the /opt/red/blue filesystem will become empty. (The same exception as in case 1 applies in /opt/red directory.)

 

This is basic POSIX filesystem and shell command behavior, not really anything specific to HP-UX. You would get the same results on Linux, or on any other Unix-style OS.

MK
Dennis Handly
Acclaimed Contributor

Re: Directory removal on HP-UX

>1) If a file system is mounted on mount point /opt/red/blue.
>what will happen If I issue rm -rf /opt/red/blue/*

 

If you have the right permissions, you'll remove all files and directories under blue/.

>(I) If I issue rm -rf /opt/red/blue/dir1/*

 

You will remove all files and directories under dir1/.

>(ii) If I issue rm -rf /opt/red/*

 

You will remove all files and directories under red/.

>I don't have access to HP-UX test server and don't want to try any destructive commands

 

Other than NFS, you can create and remove your own directory trees.