[lug] I need help from a bash scripting guru

Paul E Condon pecondon at mesanetworks.net
Mon Jan 7 17:26:29 MST 2008


comm -13 does exactly what I want.

As to the request about characters that will work for files from other
OS - What I was trying to ask for was a character that would work for
POSIX files, for netatalk representation of Mac OSX files and for
Samba representations of Windows files. The goal being a backup system
that works smoothly on a Linux based file server. _but_ I'm confident
that comm will do that because it has no concept of a field separator
which requires disabling.

So comm works for me!

Thanks, and good luck on the paying work!


On Mon, Jan 07, 2008 at 02:15:24PM -0700, Jeffrey Haemer wrote:
> Paul,
> 
> Okay, sorry it took me a while to read this and actually think about it.  My
> desktop box has been crashing all day and I'm trying to get (paying) work
> done. :-)
> 
> You probably want comm(1), not join(1).  Something like "comm -13 newlist
> oldlist" may just do the trick.
> 
> That said, I doubt that anything, even Windows, will have embedded ^A
> characters, so something like this may do it for you, too:
> 
>  join -t$'\x01' -v 2 list1 list2
> 
> If I'm wrong, pick a different control character, like $'\r'.  Even better
> would be to use $'\x00' as the delimiter, but that makes join(1) vomit.  I
> suspect a join bug, but perhaps it's bash.
> 
This vomiting is added complication to what I was trying to do with join. 


> Hope this helps.
> 
> On Jan 6, 2008 5:17 PM, Paul E Condon <pecondon at mesanetworks.net> wrote:
> 
> > I'm working on a file backup script that has a feature
> > of my own design. I have written a script that uses
> >
> >  cp -au --backup=t <srcdirpath> <backupdirpath>
> >
> > for the bulk of the work. With these options
> > (particularly --backup=t) all old versions of files that
> > change are preserved in the backup.
> >
> > I like this for grabbing clean copies of things that I
> > have accidentally clobbered. But I wanted more ---
> >
> > I also wrote a few lines that check if a file has been
> > deleted from the source and writes, for such file, a
> > record into the backup giving the time/date when a
> > backup process first noticed that the file was missing.
> >
> > To do this, I produce two files of the names of files
> > in both the source using
> >
> > find . -type f | sort > <filenamelist>
> >
> > to create a sorted list of file names for source and
> > backup and then use
> >
> > join -j 1 -v 2 <sourcelist> <backuplist> >missinglist
> >
> > ( the -v 2 writes records from the second input that don't
> > join to any record from the first input)
> >
> > This works fine so long as there are no spaces in any of the file
> > names.  Now I want to make it work for spaces and general garbage in
> > the file name. I have almost a solution: with -t \` added to the join
> > command, the accent-grave, or 'back-quote' character becomes the field
> > delimiter in join. This works fine so long as there are no back-quotes
> > in any of the file names, and there aren't any --- so far. But I'd
> > like a more bullet proof solution.
> >
> > Is there some way to tell join to use, for example, the line-feed
> > character as field delimiter? Or some other character which should
> > never appear in proper file names under UNIX, or Mac OSX, as
> > implemented by netatalk, or Windows names as handled by Samba? Put
> > another way - Is there one character that never appears in file names
> > of all these OSs, and can be introduced as the field delimiter into
> > GNU join?
> >
> > TIA
> > --
> > Paul E Condon
> > pecondon at mesanetworks.net
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> >
> 
> 
> 
> -- 
> Jeffrey Haemer <jeffrey.haemer at gmail.com>
> 720-837-8908 [cell]
> http://goyishekop.blogspot.com

> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug

-- 
Paul E Condon           
pecondon at mesanetworks.net



More information about the LUG mailing list