|
|
Subscribe / Log in / New account

Interesting discussion on ETXTBSY

Interesting discussion on ETXTBSY

Posted Aug 23, 2021 1:26 UTC (Mon) by Wol (subscriber, #4433)
In reply to: Interesting discussion on ETXTBSY by neilbrown
Parent article: The shrinking role of ETXTBSY

And so, very annoyingly, does cp.

If the target is a pre-existing directory, it copies into it. If the target is a pre-existing file it overwrites it. And if the target doesn't exist, it makes a copy called the target.

In other words, if you are copying directories in a script, you need a whole bunch of wrapper code if you want the results to be reproducible.

Cheers,
Wol


to post comments

Interesting discussion on ETXTBSY

Posted Aug 23, 2021 5:01 UTC (Mon) by mchapman (subscriber, #66589) [Link]

In other words, if you are copying directories in a script, you need a whole bunch of wrapper code if you want the results to be reproducible.

You can use cp -R source/. dest/, which will do the right thing whether or not dest is an existing directory.

With GNU cp, you can also do cp -R --no-target-directory source/ dest/.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds