From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: gnuist006@hotmail.com (gnuist006) Newsgroups: gmane.emacs.help 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 Organization: http://groups.google.com/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1042502823 16015 80.91.224.249 (14 Jan 2003 00:07:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 14 Jan 2003 00:07:03 +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 18YEbc-00049g-00 for ; Tue, 14 Jan 2003 01:07:00 +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 18YEaN-0006ay-02 for gnu-help-gnu-emacs@m.gmane.org; Mon, 13 Jan 2003 19:05:43 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: gnu.misc.discuss,comp.lang.lisp,gnu.emacs.help Original-Lines: 48 Original-NNTP-Posting-Host: 209.178.176.95 Original-X-Trace: posting.google.com 1042502596 32065 127.0.0.1 (14 Jan 2003 00:03:16 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: 14 Jan 2003 00:03:16 GMT Original-Xref: shelby.stanford.edu gnu.misc.discuss:79551 comp.lang.lisp:102941 gnu.emacs.help:108928 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:5456 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5456 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