[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: grep "\" ... how



> I this case the '\'s that appear in #include statements are the ONLY
> ones that need to be changed, so I can look for #include.

Good.  So you need to change `\` to `/` in lines that start with
'#include':

	cat file.c |sed -e '/^[ \t]*#include/ s,\\,/,g' >outfile.c

That I think should do it.  If it fails, at least you should be on the
right track.

(Basically it means "On every line that starts with optional whitespace
followed by an include statement, substitute all instances of
backslashes with slashes".)

And for homework, study regular expressions (man grep) and sed (man
sed).  As someone said, you could also try learning perl.  Actually, vi
or emacs's search and replace facilty can also do this quite easily.

Luck porting your program!


Reply to: