On Sat, Mar 09, 2002 at 11:36:08PM -0800, Troy May wrote:
> How do you write to the beginning of a file?

That's an easy one: Just turn the file around, and append to its end.

# cat > regular
first
second
third
^D
# mkfifo backwards
# while : ; do tac regular > backwards; done &
[1] 18464
# cat backwards
third
second
first
# echo fourth >> regular
# cat backwards
fourth
third
second
first
# _

Now you can easily replace the last two steps with perl. You
append to the "regular" file and read from the "backwards" one.

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to