Help required on scripting the rm -f command

When i execute rm -f $1 via a script file named rmf, it is not deleting all the files, say starting with "sec". i have execute rmf for many times to remove all the occurrences...

$rmf sec* - this should delete all files starting with sec, but not.

The rm -f sec* is working fine. kindly help me to crate a script file for this command.

</div>

Is this part of a bigger script, or are you just trying to save yourself some keystrokes? Wouldn't it be easier to just alias rm -f to rmf?

When you type the command, the shell replaces 'sec*' by the list of files slected by this pattern :

> ls sec*
sec1.dat  sec2.dat  sec3.dat
> set -x
> rmf sec*
+ rmf sec1.dat sec2.dat sec3.dat
>

In your script, you delete only the first file ($1).
If you want to delete all the files you must specify "$@":

rm -f "$@"

Jean-Pierre.

  • is replaced by all the files in the directory you are standing.
    so your scripts gets $1 as the first file, and $2 as the second and and and
    maybe you could use getops for that