> tac is the opposite to cat
> maybe something like
>       tac text.txt > reversed
>       echo "the line to insert" >> reversed
>       tac reversed > text.txt

I was trying to do something like that too, but came up with another way that I 
suspect is more efficient than reversing files ...

echo "the line to insert" | cat - text.txt > /tmp/newfile$$
cp -b /tmp/newfile$$ text.txt   # -b makes a backup

I'm trying to think of a way that doesn't use an intermediate file, not that it 
would be any more efficient given the whole file will be re-written no matter 
what you do.  I tried using less with unlimited memory buffers (-b-1) instead 
of cat, but it doesn't work any better, probably because of how pipes work.

- Rog
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to