Re: GNU make - word position in list
"Colin S. Miller" <[email protected]> Wed, 21 Apr 2010 20:49:20 +0100
| Newsgroups | gmane.comp.gnu.utils |
|---|---|
| Organization | SunSITE.dk - Supporting Open source |
| Message-ID | <[email protected]> |
Mathieu Zhang wrote:
> Hi all,
>
> I have one source pdf file source.pdf, that I want to use pdftk to
> split into multiple files such that the n-th file on the target list
> is the n-th page from source.pdf
>
> TARGETS = "foo.pdf bar.pdf more_foo.pdf ... "
>
> What I want, is to have a rule like this:
>
> ${TARGETS} : source.pdf
> pdftk A=$? cat A# output $@
>
> where # is the position of $@ inside the list ${TARGETS}. I see a lot
> of buildin pattern matching and substitution functions, but I don't
> see anything that help find the matching position.
>
> Any idea?
>
> --MZ
MZ,
Untested massive overkill
pdftk A=$? cat A$(( echo ${TARGETS} | tr '[[:space:]]' '\n' | grep -vE ^$ | grep -ix $@ | cut -d: -f1 )) output $@
but you might be better writing a helper app to do it for you.
HTH,
Colin S. Miller
--
Replace the obvious in my email address with the first three letters of the hostname to reply.