Article View: gnu.misc.discuss
Article #2155Re: A very simple question on SED or AWK for a GURU, possibly a lisp script or emacs batch processing of many files
From: ericjb
Date: Tue, 14 Jan 2003 18:18
Date: Tue, 14 Jan 2003 18:18
42 lines
2325 bytes
2325 bytes
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
Technical Details
Message-ID:
<uadi34mue.fsf@lksejb.lks.agilent.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!news.isc.org!agilent.com!not-for-mailReferences:
<b00bb831.0301131603.34e9704c@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,1e8c4b23af1e4636 X-Google-Attributes: gid103b8b,public X-Google-Thread: f4fd2,1e8c4b23af1e4636 X-Google-Attributes: gidf4fd2,public X-Google-Thread: 1025b4,1e8c4b23af1e4636 X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 2003-01-14 10:18:04 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!news.isc.org!agilent.com!not-for-mail From: ericjb@lksejb.lks.agilent.com Newsgroups: gnu.misc.discuss,comp.lang.lisp,gnu.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 Lines: 42 Sender: ericjb@LKSEJB Message-ID: <uadi34mue.fsf@lksejb.lks.agilent.com> References: <b00bb831.0301131603.34e9704c@posting.google.com> NNTP-Posting-Host: cswreg.cos.agilent.com X-Trace: cswtrans.cos.agilent.com 1042568283 22050 130.29.154.45 (14 Jan 2003 18:18:03 GMT) X-Complaints-To: usenet@cswtrans.cos.agilent.com 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/)