Interesting. That approach sort of follows one of my approaches on writing software when I have no clue exactly what I'm trying to do. Just write, as your program, something like "copy all files except the files already present" or "maintain a database of files and their locations on storage such that queries can be made about the state of backup of all files, for example 'list all files without at least 3 copies on different media'"...
On the other hand, as someone already said, rsync does all the original questioner seems to want and more (MUCH more!). On Sat, 2025-07-05 at 21:27 -0700, Eric Oyen via PLUG-discuss wrote: > What about an if-then statement in the script, like so: > for f in *.*; > do > > > If exist /path to destination folder/$F [File in question] then > diff $F /path to destination/$f and check which way the > pipe points. > if pipe points left (indicating destination file is newer, > larger, etc than original file > bypass $F > Else cp $F to /path to destination/$F > :done > > Now, the above looks strange, but it’s my methodology for writing > actual bash scripts. Firstly, define the problem in plain English, > then look up the appropriate commands and actions. It’s very basic, > but it does allow me to codify my thought processes. > > Do with it what you will. > > -Eric > From the Central Offices of the Technomage Guild, Software > maintenance infrastructure Dept. > > > On Jul 5, 2025, at 9:15 AM, Arun Khan via PLUG-discuss > <[email protected]> wrote: > > > > On Sat, Jul 5, 2025 at 8:53 AM Michael via PLUG-discuss > <[email protected]> wrote: > > Simple question: How does one copy all files except those exiting > > already? > > --------------------------------------------------- > > > > > IMO, rsync is better for your objective. It does a file by file > comparison and copies only that have changed or do not exist in the > dest dir. > > > > rsync -aP --log-file=/var/tmp/rsync-$$.log <origin dir> <dest dir> > > -- > Arun Khan > --------------------------------------------------- > PLUG-discuss mailing list: [email protected] > To subscribe, unsubscribe, or to change your mail settings: > https://lists.phxlinux.org/mailman/listinfo/plug-discuss > > --------------------------------------------------- > PLUG-discuss mailing list: [email protected] > To subscribe, unsubscribe, or to change your mail settings: > https://lists.phxlinux.org/mailman/listinfo/plug-discuss --------------------------------------------------- PLUG-discuss mailing list: [email protected] To subscribe, unsubscribe, or to change your mail settings: https://lists.phxlinux.org/mailman/listinfo/plug-discuss
