Why does 'cp -f' not work anymore?
Michael Velez
mikev777 at hotmail.com
Thu Nov 3 18:32:34 UTC 2005
-----Original Message-----
From: redhat-list-bounces at redhat.com [mailto:redhat-list-bounces at redhat.com]
On Behalf Of Chris W. Parker
Sent: Thursday, November 03, 2005 12:58 PM
To: General Red Hat Linux discussion list; cs at zip.com.au
Subject: RE: Why does 'cp -f' not work anymore?
Michael Velez <mailto:mikev777 at hotmail.com>
on Thursday, November 03, 2005 4:19 AM said:
> cp()
> {
> [ $((`expr " $*" : '.* -[a-zA-Z]*f[a-zA-Z]* .*'`)) -ne 0 ] ||
> [ $((`expr " $*" : '.* --force .*'`)) -ne 0 ] ||
> set -- -i ${1+"$@"}
> command cp "$@"
> }
>
> This function checks for --force and -f anywhere on the command line,
> as well as it allows options to be combined with -f, such as -rfv.
Awesome!
Thanks Cameron and Michael.
Chris.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
You're welcome. Actually, I noticed a slight problem after I sent it out.
The below should fix it. I added a space between the $* and the end quote
in the first expression of expr. The above function would not have worked
if -f or --force were at the end of the line. The function below does.
Every time I send out an example of a script or function, there ends up
being a mistake. I apologize for the resend. In any case, you have to
check that this works for you.
I am now using this same function for rm and mv.
cp()
{
[ $((`expr " $* " : '.* -[a-zA-Z]*f[a-zA-Z]* .*'`)) -ne 0 ] ||
[ $((`expr " $* " : '.* --force .*'`)) -ne 0 ] ||
set -- -i ${1+"$@"}
command cp "$@"
}
Michael
More information about the redhat-list
mailing list