From: Alan Mackenzie<none@example.invalid>
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: Tue, 14 Jan 2003 22:54:19 +0000 [thread overview]
Message-ID: <re420b.v5.ln@acm.acm> (raw)
In-Reply-To: b00bb831.0301131603.34e9704c@posting.google.com
gnuist006 <gnuist006@hotmail.com> wrote on 13 Jan 2003 16:03:15 -0800:
> Here is the type of lines I have in a file:
> junk label="junk1/junk2/junk3/.../junkn/" more junk
> I want to find every line that has
> label="..."
> pattern
> and then I want to replace every / by _ inside the
> quotes.
Sounds like awk could be your tool of choice. Using gawk:
cat file |
gawk 'BEGIN {FS = "\""; OFS = "\""}; /[a-zA-Z_0-9]+=/ {gsub("/", "_", $2)}; {print}'
(or something very like it) will do the job. Note: I haven't tested
this. The solution assumes that the "junk" at the beginning of each line
doesn't contain any "s.
I would guess that alternative solutions, whether in Emacs lisp or
perl or whatever would be much longer than this one-liner. The
newsgroup comp.lang.awk might be a better place to ask such questions.
Alternatively, email me if the above gawk program doesn't "quite" work,
or you want me to explain it.
> gnuist.
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
next prev parent reply other threads:[~2003-01-14 22:54 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
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 [this message]
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=re420b.v5.ln@acm.acm \
--to=none@example.invalid \
/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).