[lug] I need help from a bash scripting guru

Jeffrey Haemer jeffrey.haemer at gmail.com
Mon Jan 7 14:15:24 MST 2008


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.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20080107/74a935f0/attachment.html>


More information about the LUG mailing list