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

Re: Help with command - cp



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 2014-01-26 21:48, Mathias Bauer wrote:
> * Felix C. Stegerman wrote on 2014-01-26 at 15:49 (+0100):
> 
>> On 2014-01-26 15:26, Lisi Reisz wrote:
>>> I am wanting to use the CLI to copy some files from dirA to 
>>> dirB.  I want to exclude all hidden files.  Will this command 
>>> achieve it?
>> 
>> I prefer using rsync instead:
>> 
>> $ rsync --dry-run -av --progress --exclude='.*' /path/to/A/
>> /path/to/B/
>> 
>> * The slashes after A and B are important.
> 
> No, you only have to take care about the trailing slash of the 
> source A.  See rsync(1):
> 
> A trailing slash on the source changes this behavior to avoid 
> creating an additional directory level at the destination. You can
> think of a trailing / on a source as meaning "copy the contents of
> this directory" as opposed to "copy the directory by name", but in
> both cases the attributes of the containing directory are
> transferred to the containing directory on the destination.  In
> other words, each of the following commands copies the files in the
> same way, including their setting of the attributes of /dest/foo:
> 
> rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo
> 
> The trailing slash of the target directory B is irrelevant:
> 
> $ mkdir -p foo/dir $ touch foo/file foo/dir/file foo/.hidden
> foo/dir/.hidden $ rsync -av --exclude='.*' foo target1 $ rsync -av
> --exclude='.*' foo target2/
> 
> The results are identical directories ./target1 and ./target2. Of
> course, both need not exist.

You're right.  I always use trailing slashes on both sides, because
that way both rsync and cp behave as I expect them to.

> Regards, Mathias


- - Felix

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCgAGBQJS5YdqAAoJELIY/ywn/GzGUmsQAKlXbyJ8gEyVBMt5BfMrerTD
QTCCJWXiANMgYgRJsSfqxIYvKarh/efFC58XrV5XB/gqy2ov6sEIjCa7ZANRwk6j
hwVwUDz3et4MWaeoYpFIAn01U33UZj1RxpO2EfEXF8if7nSe87ctjeC/ulmuWDHJ
nsTNn9vN3mEigBFAWDVQ4sBIS+0tQNhHkFUUJTcAU98qvbUjNrynj8EsL0MNoIti
4bw6KbRU1ApCOe522G8q7pPHac9EXKp8DZvnjnKbC92VaI6JxqvWQ9b5IDoQ7y7W
Zbc2leTiFhJHfPz0F9dojxMTmO3Eb2Y4+nGisUBveq3WLa2lpQsIwJSfZE3lZ7Zf
bAllluz3hVTbwyGV9hRT+qocVLEL1Ya+UYB5ktnYpIOZ/eTqTJcDhvx0ZXrojceY
1c8V2a1Jf0Ht/+4yyuBie156pQn+8bps7EdFf3rrJhN4Te5UrlOYg095V4Cur/8d
ZgQ4Jt32RE9ri/rELwsYJ1HbuP3VR7I0RablHHwzlSCWO3JNk8OCmgZg8Y0IBSD0
qwa2X8WOtqvvsQzBrcUIJ0FXOJ6Im64eoNf334nUTvlZIYE5rV2sm9dMvSiMlVLS
sug0dxczH6/jHtIkH44ayrRylrNzLCwyK2fH3ykzotSBJJNo9K8ZfQb6HpFOVXtM
EH1ChAvkDi8SXIYqnOuD
=VhGP
-----END PGP SIGNATURE-----


Reply to: