Operating System - HP-UX
1827332 Members
5768 Online
109963 Solutions
New Discussion

Re: Removing files recursively

 
SOLVED
Go to solution
Chern Jian Leaw
Regular Advisor

Removing files recursively

Hi,
I tried removing a filesystem i.e nwd.256k.cr.2 by using:
rm -r nwd.srtl.cr

The annoying thing is it produces the following prompt, for each directories under this filesystem:
rm: remove write protected file nwd.256k.cr.2/v0_archive/central_inputs ?

Note that the filesystem nwd.256k.cr.2 has the following permission mode:
drwxr-xr-x usr1 nwd.256k.cr.2

How do I actually write a script to remove these sorts of filesystem recursively, without having to answer these prompts?

Thanks.
3 REPLIES 3
T G Manikandan
Honored Contributor
Solution

Re: Removing files recursively

Hello,
It is a good practice where the system prompts for removing a file.
I assume you are working on c shell.
There is a alias set on your profile for rm command as rm -i
So to remove the directory without being interactive

just use
$unalias rm
$rm -r
else you can use the force option.
$rm -rf

You should be usr1 user to delete your directory
steven Burgess_2
Honored Contributor

Re: Removing files recursively

Hi Chern

If a user does not have write permission for a file to be removed and
standard input is a terminal, a prompt containing the file name and
its permissions is printed requesting that the removal of the file be
confirmed (see Access Control Lists below). A line is then read from
standard input. If that line begins with y the file is deleted;
otherwise, the file remains. No questions are asked when the -f
option is given or if standard input is not a terminal.

If file is of type directory, and the -f option is not specified, and
either the permissions of file do not permit writing and standard
input is a terminal or the -i option is specified, rm writes a prompt
to standard error and reads a line from standard input. If the
response does not begin with y, it does nothing more with the current
file and goes on to any remaining files.

Also

Use the -exec command to perform actions after a command ,ie

find . -size +10000000c -exec ll {} \; | more

Hope this helps

Steve



take your time and think things through
Chern Jian Leaw
Regular Advisor

Re: Removing files recursively

TG,
I used the rm -rf , and it worked!

Thanks.