[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-27 02:04, Mathias Bauer wrote:
> * Felix C. Stegerman wrote on 2014-01-26 at 23:58 (+0100):
> 
>> On 2014-01-26 23:24, Mathias Bauer wrote:
> 
>>> * Mr Smiley wrote on 2014-01-26 at 20:56 (+0000):
>>> 
>>>>> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B
>>>> 
>>>> If you don't put a / after B it will copy all files to a file
>>>> called B
>>> 
>>> No, obviously not.
>>> 
>>> [...]
>> 
>> It does if there's only one file in A and B does not exist.
>> 
>> $ mkdir A; echo HI >> A/foo $ cp -a A/* B $ cat B HI
> 
> Yes, but ... come on, that's a rather trivial shell expansion! By
> the way, don't you consider it a little bit strange to change the
> original problem conditions *afterwards*?
> 
> * Lisi Reisz wrote on Sun, 26 Jan 2014, at 14:26 (+0000):
> 
>> I am wanting to use the CLI to copy some files from dirA to dirB.
>> I want to exclude all hidden files.
> 
> Read ... file*S*.
> 
> Regards, Mathias

You're absolutely right *in this context*.  But if you're not aware
that the command will behave differently when there's only one file,
you may run into trouble later on when you use it in a different
context.  That's why I mentioned it.  So people don't expect it to
work in the same way with *any number* of files.  You'll also get
different results if there are *no files* (unless you use nullglob).


- - Felix

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

iQIcBAEBCgAGBQJS5bXcAAoJELIY/ywn/GzG5GQP+gOx4MFOs+Gee5XKk4E7Xkwn
nkem4A0jMvHpIVWIm1+f79D/VoV93oyM4EbL/ppeRY3zco1TjfxWMwjxB2tLNrEM
y58q2+n0/4wsrtyc5CKFRAtw2xGNhkZLezXMBk0sm62zlAXt5qQDUgUMqLfyl+nn
Ha0eR9tVWpEiLQVi0TZl7Mn/TvKwvN2DlcrOp5urgB8q6CerZiUGcxteblQSkRQm
8h2a8q4sNeT0m/gBtxCtgG/0l4FOC0tE9swhadwHNIUDIA2W0Q3NWR4OpirVHhcF
7Mjlmt8IzEhOWh6Sq0iWd3Therg/dZsI2VXfxLyP/OpYEnIOwoHRv0HUwE8A+I1N
jaE7y0oHeT3oT0/9Og6ii5cxSFUixRVKVkIr0oaw4CEhDWm8rvyNNPUM/mlP0wlV
raslS5e9wSko3WqzrfoCN4jREC9EoYIrsjssfiQ1dqBVZVXoGOcEC1UabcLM9rSq
QshUQXGmb/oDDLXQVgtOMP1oCCJ3RNj7zgtqiiRF+9B9VrqRP5Shn3PAAFT379nq
uMJ6YSP5KOquRXs4b+iuM6KfwlNKgaxJKP9EgvoNoFMxO+IzO7LUQnNaC5L250lJ
/Vo3Q41Yo3ia9QFiE/XoNy5iOBjPnm8W8izSr+E7HWFwad7xvZiEFHfxuKKZ1vw9
8z/KqTSjHMSEQgOjtV/E
=nkeh
-----END PGP SIGNATURE-----


Reply to: