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.

Recommended Answers

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 …

Jump to Post

All 3 Replies

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.