parsing commands in a makefile

Chris Torek chris at mimsy.umd.edu
Sun Oct 22 01:24:21 AEST 1989


In article <4782 at ncar.ucar.edu> clyne at redcloud.ucar.edu (John Clyne) writes:
>... The syntax for this with sed is something like:
>
>	% sed -e "/patten/a\
>	text to append" < in_file > out_file

(Note: you need two backslashes in csh.  It would be better to show the
above as `$ sed -e ...'.)

>... The problem is in a makefile all rules must be contained on a single
>line. If you try something like the following in a makefile:
>
>target:
>	sed -e "/pattern/a\
>	text to append" < in_file > out_file
>[it fails; is there a workaround?]

The only way to do this is indirectly.  For instance:

	sed -e `echo '/pattern/a\Xtext to append' | tr X '\012'`

If you are using the !@* Sys5 `interpreting echo', you need to double
the backslash.  Also, neither `pattern' nor `text to append' can contain
an `X'.

In general, it is easier to put the `sed' command(s) into a separate
file (either with `sh cmdfile.sh' or `sed -f file.of.sed.commands').
-- 
`They were supposed to be green.'
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list