[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A very simple question on SED or AWK for a GURU, possibly a lisp scr
From: |
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 |
User-agent: |
Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (powerpc-apple-darwin) |
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;
}
- 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/13
- Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files,
Christopher J. White <=
- Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files, Friedrich Dominicus, 2003/01/14
- Re: 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
- Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files, ericjb, 2003/01/14
- Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files, Alan Mackenzie, 2003/01/14
- Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files, Kaz Kylheku, 2003/01/14