sed can read files; you don't have to 'cat' them to it

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sat Feb 16 08:50:26 PST 2013


On Sat, 16 Feb 2013, Cristian Ionescu-Idbohrn wrote:
>
> Here's an example:
>
> $(NSIFILE): $(NSIINPUTFILE)
> 	$(shell cat $(NSIINPUTFILE) | sed -e 's/VERSIONTOKEN/$(VERSION_STRING)/;s/PRODVTOKEN/$(PRODVERSION_STRING)/' > $(NSIFILE))
>
> I would do it like this, instead:
>
> 	$(shell sed -e 's/VERSIONTOKEN/$(VERSION_STRING)/;s/PRODVTOKEN/$(PRODVERSION_STRING)/' $(NSIINPUTFILE) >$(NSIFILE))
>
> unless there's a good reason for keeping it as is (I don't do windos nor
> mac).

More thoughts.  Use double quotes around the regexp, as single quotes
don't expand variables:

	$(shell sed -e "s/VERSIONTOKEN/$(VERSION_STRING)/;s/PRODVTOKEN/$(PRODVERSION_STRING)/" $(NSIINPUTFILE) >$(NSIFILE))


Cheers,

-- 
Cristian


More information about the subsurface mailing list