Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!ucbvax!bloom-beacon!bloom-beacon!lfk From: lfk@athena.mit.edu (Lee F Kolakowski) Newsgroups: comp.unix.questions Subject: Re: Changing back slashes to forward slashes Message-ID: <1990Aug16.203339.15530@athena.mit.edu> Date: 16 Aug 90 23:33:32 GMT References: <1990Aug16.194644.14376@athena.mit.edu> Sender: daemon@athena.mit.edu (Mr Background) Organization: Mass. Inst. of Tech., Dept. of Chemistry Lines: 57 In-Reply-To: ramon@skye.mit.edu's message of Thu, 16 Aug 90 19:46:44 GMT On Thu, 16 Aug 90 19:46:44 GMT, ramon@skye.mit.edu (Ramon F Herrera) said: > I have a question for those {sed, grep, awk, tr} wizards out there. > I'd like to change all the occurrences in a file of a line like this: > #include "dira\dirb\incl.h" > to > #include "dira/dirb/incl.h" > but only for the lines that begin with "#include". Try: awk ' { if ($0 ~ /^#include/) gsub(/\\/, "/") print }' filename Frank Kolakowski ====================================================================== |lfk@athena.mit.edu || Lee F. Kolakowski | |lfk@eastman2.mit.edu || M.I.T. | |kolakowski@wccf.mit.edu || Dept of Chemistry | |lfk@mbio.med.upenn.edu || Room 18-506 | |lfk@hx.lcs.mit.edu || 77 Massachusetts Ave.| |AT&T: 1-617-253-1866 || Cambridge, MA 02139 | |--------------------------------------------------------------------| | #include | | One-Liner Here! | ====================================================================== -- Frank Kolakowski ====================================================================== |lfk@athena.mit.edu || Lee F. Kolakowski | |lfk@eastman2.mit.edu || M.I.T. | |kolakowski@wccf.mit.edu || Dept of Chemistry | |lfk@mbio.med.upenn.edu || Room 18-506 | |lfk@hx.lcs.mit.edu || 77 Massachusetts Ave.| |AT&T: 1-617-253-1866 || Cambridge, MA 02139 | |--------------------------------------------------------------------| | #include | | One-Liner Here! | ======================================================================