scripting text replacement

Jonathan McKeown jonathan+freebsd-questions at
Sun Nov 9 22:53:46 PST 2008

On Sunday 09 November 2008 00:02:11 Giorgos Keramidas wrote:
> On Sat, 8 Nov 2008 19:43:52 +0100, bsd <bsd at> wrote:
> > I have a file containing a list of items like that:
> >
> > line1item1 line1item2 line1item3
> > line2item1 line2item2 line2item3
> > …400 times
> >
> > I need to insert this into another text file using printf() items should
> > be converted into variable looping… like that:
> >
> > printf "Bla bla bla $1 bla bla $2 bla bla $3 bla bla $2"

> A little more detail about the "Bla bla" part may be important in our
> effort to help you effectively.  What you seem to describe above may be
> trivial to do with awk(1):

More detail definitely needed. When you say insert into another text file, do 
you mean you want to create an output file in which each line is identical 
bar the four parameters from the first file (in other words your bla bla bla 
is the same for every input line) (in which case a simple awk '{printf}' will 
meet the need), or are you actually doing a merge of two files where bla bla 
bla represents the text from the next line of the other input file and 
changes from line to line?


More information about the freebsd-questions mailing list