0

I have a directory with a bunch of stuff in it. when you say rm -r "the directory"
you have to say yes,yes,yes,......20 times. Is there a script for just having the
answer to all "are you sure you want to delete ...?" be yes? any scripting help, im new.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by masijade
1

The behaviour you describe means that a -I option is silently passed to rm. Usually it is done by aliasing rm to rm -I somewhere in the startup scripts; some people think it is a good idea. The simplest way is to directly invoke /bin/rm instead. If you are writing a script, a full path to an external executable is a must anyway. If you are just annoyed at the command line, search your startup scripts for rm, and comment out the aliasing.

0

Use rm -f instead..
To check whether rm is aliased or not use which rm .
To stop shell from resolving aliases use "\" at front, i.e. \rm would not resolve an alias if rm is aliased.

Also the following works (not a good idea in this case but you learn redirection):

for myFile in `ls -l /tmp/mydir`
do
    rm /tmp/mydir/$myFile << EO_INPUT
yes
EO_INPUT
done
0

Correct escaping the call (with "\") to effectively inline "unalias" the command is the proper way to go.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.