all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: gnuist006@hotmail.com (gnuist006)
Subject: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files
Date: 13 Jan 2003 16:03:15 -0800	[thread overview]
Message-ID: <b00bb831.0301131603.34e9704c@posting.google.com> (raw)

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.

For the purposes of continuity, I want the script to look like this:

cat file |
sed commands |
awk commands |

etc.

I do not care if it all sed or awk or in what order.

Note that the junk is usually alphanumeric with dots etc but no slashes.
So it can be represented by [^/]* if / is considered non-special otherwise
escape it. There may be other /'s on the line outside the pattern 
the double quotes starting with label= and they must not be changed.

This problem can be described as making changes to a pattern matching a
regexp. It is not the problem of making changes to a pattern in the whole
line contaning a regexp. That is what is making it difficult for me.
The other reason is that I do not have a definite number of slashes in
the pattern in the single quote otherwise I would use the tagged expression.

I hope you to enjoy this problem. I put on the net only after wrestling it
with some.

gnuist.

BTW, I can do this kind of operation inside emacs. However, I do not know
how to write an lisp script. Or how to automatically load 100s or files
one after another in emacs, run a function on them and then store their
output to another file. Then close these buffers and go to the next file.
I would like as many approaches to this problem as possible, ie
sed
awk
lisp script
lisp in emacs

             reply	other threads:[~2003-01-14  0:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-14  0:03 gnuist006 [this message]
2003-01-14  3:46 ` 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
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b00bb831.0301131603.34e9704c@posting.google.com \
    --to=gnuist006@hotmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.