From owner-freebsd-questions@FreeBSD.ORG Sat Feb 7 09:09:14 2009 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 55D91106566B for ; Sat, 7 Feb 2009 09:09:14 +0000 (UTC) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from wojtek.tensor.gdynia.pl (wojtek.tensor.gdynia.pl [IPv6:2001:4070:101:2::1]) by mx1.freebsd.org (Postfix) with ESMTP id 7D57A8FC12 for ; Sat, 7 Feb 2009 09:09:12 +0000 (UTC) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from wojtek.tensor.gdynia.pl (localhost [IPv6:::1]) by wojtek.tensor.gdynia.pl (8.14.3/8.14.3) with ESMTP id n17995nY049635; Sat, 7 Feb 2009 10:09:05 +0100 (CET) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Received: from localhost (wojtek@localhost) by wojtek.tensor.gdynia.pl (8.14.3/8.14.3/Submit) with ESMTP id n17993u1049632; Sat, 7 Feb 2009 10:09:04 +0100 (CET) (envelope-from wojtek@wojtek.tensor.gdynia.pl) Date: Sat, 7 Feb 2009 10:09:03 +0100 (CET) From: Wojciech Puchar To: Adam Vande More In-Reply-To: <498CBEBE.7080702@gmail.com> Message-ID: <20090207100621.X49625@wojtek.tensor.gdynia.pl> References: <498CBEBE.7080702@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-questions@freebsd.org Subject: Re: insert new line in files 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: Sat, 07 Feb 2009 09:09:14 -0000 > I want to insert a new line of text at a certain position in certain files > recursively under a directory. More specifically, I want text like this: > > include('/usr/home/www/imp-sites/default_inventory.php'); write a script: #!/usr/local/bin/bash (a=0 while [ $a -lt 36 ];do read line echo "$line" a=$[a+1] done echo "include('/usr/home/www/imp-sites/default_inventory.php');" while read line;do echo "$line" done) <$1 >/tmp/$$ mv -f /tmp/$$ $1 run it over each file