rm command silently

Hi,
 In one of my scripts the command is to remove all the files in a directory. sometimes there will be files and sometimes not..but if the files are not there then this commad is generating error.
"* No such File or Directory"
the actual command is rm ./DIR/*
in some of the commands i know we have -s option which will supress the error. Is there anything like that here ?
LVL 8
koppchaAsked:
Who is Participating?
 
brettmjohnsonCommented:
use rm -f:

rm -f ./DIR/*


From the 'rm' man page [note the second sentence]:

     -f          Attempt to remove the files without prompting for confirma-
                 tion, regardless of the file's permissions.  If the file does
                 not exist, do not display a diagnostic message or modify the
                 exit status to reflect an error.  The -f option overrides any
                 previous -i options.
0
 
koppchaAuthor Commented:
I was knowing about -f that it would forcibly removes the files but not aware that it can do this alos...
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.