From: chris@grierwhite.com (Christopher J. White)
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 [thread overview]
Message-ID: <m2vg0stmv8.fsf@bluesteel.grierwhite.com> (raw)
In-Reply-To: b00bb831.0301131603.34e9704c@posting.google.com
Here's my quick perl solution...
Save as "junk.pl", then run as "junk.pl <file1> <file2> <file3> ... ".
Each file is renamed to <file>.old, output <file>. 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 = <INFILE>) {
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;
}
next prev parent reply other threads:[~2003-01-14 3:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-14 0:03 A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files gnuist006
2003-01-14 3:46 ` Christopher J. White [this message]
2003-01-14 7:13 ` Friedrich Dominicus
2003-01-14 8:42 ` gnuist006
2003-01-14 10:23 ` Friedrich Dominicus
2003-01-14 22:10 ` Wayne Throop
2003-01-14 18:18 ` ericjb
2003-01-14 19:34 ` Stefan Monnier <foo@acm.com>
2003-01-14 22:54 ` Alan Mackenzie
2003-01-14 23:19 ` Kaz Kylheku
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2vg0stmv8.fsf@bluesteel.grierwhite.com \
--to=chris@grierwhite.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).