Changing back slashes to forward slashes

Lee F Kolakowski lfk at athena.mit.edu
Fri Aug 17 09:33:32 AEST 1990


On Thu, 16 Aug 90 19:46:44 GMT,
ramon at 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 at athena.mit.edu                     ||      Lee F. Kolakowski    |
|lfk at eastman2.mit.edu                   ||	M.I.T.		     |
|kolakowski at wccf.mit.edu                ||	Dept of Chemistry    |
|lfk at mbio.med.upenn.edu		        ||	Room 18-506	     |
|lfk at hx.lcs.mit.edu                     ||	77 Massachusetts Ave.|
|AT&T:  1-617-253-1866                  ||	Cambridge, MA 02139  |
|--------------------------------------------------------------------|
|                         #include <woes.h>         		     |
|		           One-Liner Here!                           |
======================================================================


--

Frank Kolakowski 

======================================================================
|lfk at athena.mit.edu                     ||      Lee F. Kolakowski    |
|lfk at eastman2.mit.edu                   ||	M.I.T.		     |
|kolakowski at wccf.mit.edu                ||	Dept of Chemistry    |
|lfk at mbio.med.upenn.edu		        ||	Room 18-506	     |
|lfk at hx.lcs.mit.edu                     ||	77 Massachusetts Ave.|
|AT&T:  1-617-253-1866                  ||	Cambridge, MA 02139  |
|--------------------------------------------------------------------|
|                         #include <woes.h>         		     |
|		           One-Liner Here!                           |
======================================================================



More information about the Comp.unix.questions mailing list