RE: Why does 'cp -f' not work anymore?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx [mailto:redhat-list-bounces@xxxxxxxxxx]
On Behalf Of Chris W. Parker
Sent: Thursday, November 03, 2005 12:58 PM
To: General Red Hat Linux discussion list; cs@xxxxxxxxxx
Subject: RE: Why does 'cp -f' not work anymore?

Michael Velez <mailto:mikev777@xxxxxxxxxxx>
    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@xxxxxxxxxx?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

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux