From owner-freebsd-questions@FreeBSD.ORG Mon Nov 10 06:53:46 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D961106567F for ; Mon, 10 Nov 2008 06:53:46 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from hermes.hst.org.za (onix.hst.org.za [209.203.2.133]) by mx1.freebsd.org (Postfix) with ESMTP id B9ECC8FC1C for ; Mon, 10 Nov 2008 06:53:44 +0000 (UTC) (envelope-from jonathan+freebsd-questions@hst.org.za) Received: from sysadmin.hst.org.za (sysadmin.int.dbn.hst.org.za [10.1.1.20]) (authenticated bits=0) by hermes.hst.org.za (8.13.8/8.13.8) with ESMTP id mAA6hL1W029118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 10 Nov 2008 08:43:22 +0200 (SAST) (envelope-from jonathan+freebsd-questions@hst.org.za) From: Jonathan McKeown Organization: Health Systems Trust To: freebsd-questions@freebsd.org Date: Mon, 10 Nov 2008 08:59:45 +0200 User-Agent: KMail/1.9.7 References: <4B1A9F30-B8BC-4C48-A85F-3697C6AB3B7B@todoo.biz> <87skq1yizg.fsf@kobe.laptop> In-Reply-To: <87skq1yizg.fsf@kobe.laptop> X-Face: $@VrUx^RHy/}yu]jKf/<4T%/d|F+$j-Ol2"2J$q+%OK1]&/G_S9(=?utf-8?q?HkaQ*=60!=3FYOK=3FY!=27M=60C=0A=09aP=5C9nVPF8Q=7DCilHH8l=3B=7E!4?= =?utf-8?q?2HK6=273lg4J=7Daz?=@1Dqqh:J]M^"YPn*2IWrZON$1+G?oX3@ =?utf-8?q?k=230=0A=0954XDRg=3DYn=5FF-etwot4U=24b?=dTS{i X-Spam-Score: -4.399 () ALL_TRUSTED,BAYES_00 X-Scanned-By: MIMEDefang 2.61 on 209.203.2.133 Subject: Re: scripting text replacement X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2008 06:53:46 -0000 On Sunday 09 November 2008 00:02:11 Giorgos Keramidas wrote: > On Sat, 8 Nov 2008 19:43:52 +0100, bsd 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? Jonathan