help-gnu-utils
[Top][All Lists]
Advanced

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

Re: GNU make - word position in list


From: Colin S. Miller
Subject: Re: GNU make - word position in list
Date: Wed, 21 Apr 2010 20:49:20 +0100
User-agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328)

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]