From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: chris@grierwhite.com (Christopher J. White) Newsgroups: gmane.emacs.help Subject: Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files Date: Mon, 13 Jan 2003 22:46:03 -0500 Organization: Posted via Supernews, http://www.supernews.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1042516237 28339 80.91.224.249 (14 Jan 2003 03:50:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 14 Jan 2003 03:50:37 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18YI5x-0007Ms-00 for ; Tue, 14 Jan 2003 04:50:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18YI5y-0003Xq-0C for gnu-help-gnu-emacs@m.gmane.org; Mon, 13 Jan 2003 22:50:34 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!gestalt.direcpc.com!telocity-west!DIRECTV!sn-xit-03!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.misc.discuss,comp.lang.lisp,gnu.emacs.help User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (powerpc-apple-darwin) Cancel-Lock: sha1:+S5URORbr7wDVq52NdOQaYmxT8E= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 43 Original-Xref: shelby.stanford.edu gnu.misc.discuss:79552 comp.lang.lisp:102953 gnu.emacs.help:108930 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5458 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5458 Here's my quick perl solution... Save as "junk.pl", then run as "junk.pl ... ". Each file is renamed to .old, output . For each Note, this assumes that there are no double quotes in the label expression to be manipulated. I can't see how you'd determine the end of the expression if this isn't true (unless double quotes might be quoted with a backslash or something). #!/usr/bin/perl foreach my $outfile (@ARGV) { my $infile = $outfile . ".old"; print "infile: $infile\n"; print "outfile: $outfile\n"; my $line, $s1, $s2, $s3; rename $outfile, $infile; open INFILE, "<$infile"; open OUTFILE, ">$outfile"; while ($line = ) { if ($line =~ /^(.*)label=\"([^\"]*)\"(.*)$/) { $s1 = $1; $s2 = $2; $s3 = $3; $s2 =~ s/\//_/g; print OUTFILE $s1 . "label=\"" . $s2 . "\"" . $s3 . "\n"; } else { print OUTFILE $line; } } close INFILE; close OUTFILE; }