Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> UNIX command cp
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