From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: ericjb@lksejb.lks.agilent.com Newsgroups: gmane.emacs.help 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: 14 Jan 2003 10:18:01 -0800 Organization: Agilent Technologies Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1042568455 31089 80.91.224.249 (14 Jan 2003 18:20:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 14 Jan 2003 18:20:55 +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 18YVg2-00084Q-00 for ; Tue, 14 Jan 2003 19:20:42 +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 18YVgf-0003hJ-06 for gnu-help-gnu-emacs@m.gmane.org; Tue, 14 Jan 2003 13:21:21 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!news.isc.org!agilent.com!not-for-mail Original-Newsgroups: gnu.misc.discuss,comp.lang.lisp,gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: cswreg.cos.agilent.com Original-X-Trace: cswtrans.cos.agilent.com 1042568283 22050 130.29.154.45 (14 Jan 2003 18:18:03 GMT) Original-X-Complaints-To: usenet@cswtrans.cos.agilent.com Original-NNTP-Posting-Date: Tue, 14 Jan 2003 18:18:03 +0000 (UTC) X-Newsreader: Gnus v5.5/Emacs 20.3 Cache-Post-Path: cswreg.cos.agilent.com!unknown@lksejb.lks.agilent.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) Original-Xref: shelby.stanford.edu gnu.misc.discuss:79557 comp.lang.lisp:103008 gnu.emacs.help:108952 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:5480 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5480 gnuist006@hotmail.com (gnuist006) writes: > 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. Can we assume that the only double quotes are those surrounding the label string? If so, you can use that to split the input file into three files, something like: cat file | cut -f1 -d\" > file1 cat file | cut -f2 -d\" > file2 cat file | cut -f3 -d\" > file3 sed 's/\//_/g' < file2 > file2.new paste -d\" file1 file2.new file3 > outputfile I didn't test this, but it might work... -- Eric Backus R&D Design Engineer Agilent Technologies, Inc. 425-335-2495 Tel