cp - Strange behaviour in recursive copy - Unix & Linux Stack Exchange
For cp
, the destination is the last argument on the command line. You have specified 2/g
as the last argument.
Before cp
is executed, the command parameters are expanded. 1/*
expands to 1/a 1/b 1/c
. 2/*
expands to 2/f 2/g
. The final executed command is cp -r 1/a 1/b 1/c 2/f 2/g
, which will copy all the arguments (except the last one) to 2/g
.
If you are intending to copy things to 2
, the second glob isn't necessary, making the command cp -r 1/* 2/
. If you are intending to copy things to multiple destinations, you can't specify that with just cp
; you can use a small loop, like the following:
Read full article from cp - Strange behaviour in recursive copy - Unix & Linux Stack Exchange
No comments:
Post a Comment