Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> UNIX command cp

UNIX command cp

From: yong huang <yong321_at_yahoo.com>
Date: Fri, 12 Jan 2001 21:27:22 -0800 (PST)
Message-Id: <10739.126608@fatcity.com>


I vaguely remember a long time ago somebody in a UNIX group says using wild cards in the cp command is dangerous, because after * expansion, the second file (the 2nd argument) gets overwritten by the first file (the 1st arg). Since then, I've always used

for i in *; do
cp $i $i.bak #or cp $i /somedir
done

But I can't reproduce that danger. Can anyone give an example?

What triggered me to ask this is an interesting incident. Recently I inherited our production server and stayed late to test the cold backup script which I modified a little bit. From ps -ef | grep cp, I saw the command:

cp /myoradatapath/system01.dbf /myoradatapath/system02.dbf

Sweats came to my forehead!!

What happens is that the C shell script the former DBA wrote is simply doing: cp /myoradatapath/* /anotherdir. But ps -ef only displays part of the expanded command.

Anyway, can anyone give an example to show that cp * *.bak or the like overwrites files? Thanks.

Yong Huang
yong321_at_yahoo.com



Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ Received on Fri Jan 12 2001 - 23:27:22 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US