Re: Help with command - cp
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
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?
> :--
>
> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B
Not quite. But close. You can get in trouble depending on how many
items are in A and whether or not B exists. And it will only ignore
hidden files if they are in A directly, not if they are in subdirectories.
I prefer using rsync instead:
$ rsync --dry-run -av --progress --exclude='.*' /path/to/A/ /path/to/B/
Notes:
* Existing files in B will be overwritten.
* You may want to look at the manpage to see what the options do.
* The slashes after A and B are important.
* The --dry-run option will show you what the command will do without
actually performing the copy -- so you can check whether it behaves as
expected. Leave it out to actually perform the copy.
* You can add the --delete option if you want to completely
synchronise the directories, as it will cause removal of files in B
that are not in A (except those excluded -- see the man page).
* If you only want to exclude hidden files in A itself (not in
subdirectories), use --exclude='/.*' instead.
> Thanks, Lisi
- - Felix
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iQIcBAEBCgAGBQJS5SBZAAoJELIY/ywn/GzG3EQQANJhaP/VLk2EcFQL+eTggCRi
qTVWmbrSsMiaj2pBOrTelThGIVXsrWCukjkuOA/vxKKtMZJD2ZtLUIAi8HSj7zzw
zLdnpQPmJgjecd8vxlw27pQkVgQfyDUOxXk4MZ9d3GQoFoZ3T21lHFfPWskZqJbL
QqJ3ZrhYU4ijbmr7YBxGNiw/Ph5nc6FwihiU9DvcoNThJy+MlIklJJVAhMu+UaZ8
i9OOCsF7zAXxkbbk1bXjn+ni6PkiKD7AkTWrCQ/4vpa448cwZCth/v9p8akuniUu
7FserEDpwJhwdTInYWO7cBBXc2a9QDC5f/bCZ+eBbgpvrFBeiBt7f2ZStElMSWbY
Gv7BQ8x3ZZPJf0H+47wN00OOEuIouOWL88FWFMNaERtc4JQsXU9C+0n/O9N8AW+/
QNMZsw8zNAr4Eu/SFt88SuIWVO/zSDCPrcG6xweEirdKE8uFXca26seTHluYusp0
xnfXSzpT21ERXn2wnNASf7WHsP9T+5hcP3V7h+0t0dwtI3vC84e+PKBGMvcl40ps
QPjtybj2Dpz0u5sobgjnFN2RnguRRLbruTyvhcbb3LFZ69nORVJEFxzKEPAGmN2n
up1OsHO4HGwRTexyI3i3C+FxKeI2SoqSBbmvHx1W+oUZCqaal7lOyB1M7aTXCp98
sCidWvwF7U1EUTeGwzKs
=wAvY
-----END PGP SIGNATURE-----
Reply to: