On Thu, 29 Jun 2000, Dallman Ross wrote:
As none of this should be relied upon, your original objection was
correct. The only correct way to do the above for an arbitrarily
...............^^^^^
large file is somthing like
sed 's/^\([^,]*\),\(.*\)/\2,\1/' < rrobinlist > rrtmp &&
mv -f rrtmp rrobinlist
Which of course has a race condition unless you use it in a locking
recipe.
I continue to hate the word "only" when I see it refering to anything
UNIX-y. :-)
Which is why I qualified it with "something *like*" ...
What about my sort kludge from yesterday? | sort -m -o file
Apparently I missed that bit of the thread. "sort -o foo foo" is "like"
because it first copies foo and then rewrites it; the point is that in
either case you use two files.
But piping to "sort -o" doesn't help if the output file isn't also named
as one of the input files ... so not having seen your original kluge, I
can't say whether it was a solution.
works fine to preserve file and negate race conditions, I believe.
Copy-then-rewrite is no better for races than rewrite-then-rename. You
just get different failure behavior.
Incidentally, with respect to the sed command itself, I think I'd prefer
that the round robin list have one address per line, rather than having
one long line with addresses separated by commas. Easier for editing,
wouldn't you say?
This moves the first line to the end:
sed -n -e 1x -e 2,\$p -e \$x -e \$p
Or if you have a modern sed,
sed -n '1x;2,$p;$x;$p'
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail