MLUG: Re: [MLUG] prepending a file
Re: [MLUG] prepending a file
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Tue, 2 Mar 2004, Brent Deterding wrote:

> I want to add some text to the top of a file - how do I do it? 
> 
> Like >> but at the beginning, not the end

If it's just a line or three, you can do this:

  awk 'BEGIN {print "text\nto\nprepend"} {print}' myinput.txt > 
  output.txt

Which has the nice property that you don't leave a junk temp file 
around.  If that's not a problem (or even a feature) you can do:

vi mytoptext.txt; cat mytoptext.txt othertext.txt > text.out

In a perfect (albeit pretty psycho) world, this would work:

    perl -pe 'BEGIN {print <>}' othertext.txt > text.out

Alas, buffering ruins your day, and setting $| doesn't help.

Oh well...

jking

_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members