From: Vincent Belaïche on


Assume I have some file foo.txt like this:


--8<--------------cut here---------------begin-------------->8---
Foo
Bar
--8<--------------cut here----------------end--------------->8---


and then under Bash I type this:


--8<--------------cut here---------------begin-------------->8---
cat foo.txt | awk '/Foo/ { print; }
END { print "The end.";}'
--8<--------------cut here----------------end--------------->8---

Then I get the following output


--8<--------------cut here---------------begin-------------->8---
Foo
The end.
--8<--------------cut here----------------end--------------->8---

Now the question is the following: how can I make the same command line
inside a Makefile rule (without the burden of going through a shell
script). It seems to me that it is impossible to insert a CR into a
logical makefile like. Furthermore any folding with `\' will insert a
blank.

Any feedback wellcome

Vincent.
From: Ben Bacarisse on
Vincent Belaïche <vincent.belaiche(a)gmail.com> writes:

> Assume I have some file foo.txt like this:
>
> Foo
> Bar
>
> and then under Bash I type this:
>
> cat foo.txt | awk '/Foo/ { print; }
> END { print "The end.";}'

<snip>
> Now the question is the following: how can I make the same command line
> inside a Makefile rule (without the burden of going through a shell
> script). It seems to me that it is impossible to insert a CR into a
> logical makefile like. Furthermore any folding with `\' will insert a
> blank.

My first reaction is just not to have the newline. Awk does not need it
so why bother?

awk '/Foo/ { print; } END { print "The end.";}' <foo.txt

works fine.

--
Ben.
From: Geoff Clare on
Vincent Bela�che wrote:

> --8<--------------cut here---------------begin-------------->8---
> cat foo.txt | awk '/Foo/ { print; }
> END { print "The end.";}'
> --8<--------------cut here----------------end--------------->8---

> Now the question is the following: how can I make the same command line
> inside a Makefile rule (without the burden of going through a shell
> script). It seems to me that it is impossible to insert a CR into a
> logical makefile like. Furthermore any folding with `\' will insert a
> blank.

Just use a ';' as the separator instead of a newline.

awk '/Foo/ { print; }; END { print "The end.";}' foo.txt

--
Geoff Clare <netnews(a)gclare.org.uk>

From: Vincent Belaïche on
Thanks !

This solves my problem!

Vincent.

Geoff Clare a �crit :
> Vincent Bela�che wrote:
>
>> --8<--------------cut here---------------begin-------------->8---
>> cat foo.txt | awk '/Foo/ { print; }
>> END { print "The end.";}'
>> --8<--------------cut here----------------end--------------->8---
>
>> Now the question is the following: how can I make the same command line
>> inside a Makefile rule (without the burden of going through a shell
>> script). It seems to me that it is impossible to insert a CR into a
>> logical makefile like. Furthermore any folding with `\' will insert a
>> blank.
>
> Just use a ';' as the separator instead of a newline.
>
> awk '/Foo/ { print; }; END { print "The end.";}' foo.txt
>