From owner-freebsd-questions@FreeBSD.ORG Wed Jun 30 03:09:54 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 76A9616A4CE for ; Wed, 30 Jun 2004 03:09:54 +0000 (GMT) Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.242]) by mx1.FreeBSD.org (Postfix) with SMTP id 40B3F43D46 for ; Wed, 30 Jun 2004 03:09:54 +0000 (GMT) (envelope-from thatha@gmail.com) Received: by mproxy.gmail.com with SMTP id x71so386095cwb for ; Tue, 29 Jun 2004 20:09:26 -0700 (PDT) Received: by 10.38.24.8 with SMTP id 8mr16576rnx; Tue, 29 Jun 2004 20:09:26 -0700 (PDT) Message-ID: Date: Wed, 30 Jun 2004 13:09:26 +1000 From: Gautam Gopalakrishnan To: Bill Moran In-Reply-To: <20040629195025.549fe8f3.wmoran@potentialtech.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200406292005.i5TK5nZ18158@clunix.cl.msu.edu> <200406291621.22848.fbsd-questions@trini0.org> <20040629195025.549fe8f3.wmoran@potentialtech.com> cc: Gerard Samuel cc: jerrymc@clunix.cl.msu.edu cc: freebsd-questions@freebsd.org Subject: Re: Means of trimming files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2004 03:09:54 -0000 On Tue, 29 Jun 2004 19:50:25 -0400, Bill Moran wrote: > > Gerard Samuel wrote: > > > find ./ -name '*.php' -exec php -r '$f = file_get_contents("{}"); $h = > > fopen("{}", "wb"); fwrite($h, trim($f)); fclose($h);' \; > > > > It did the job perfectly. $ perl -0 -pi -e 's/\n+$//s' *.php will edit each .php file and replace it too. If you want a backup, then $ perl -0 -p -i.bak -e 's/\n+$//s' *.php Cheers Gautam