LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Reg Makefile : Read file : for loop (https://www.linuxquestions.org/questions/linux-newbie-8/reg-makefile-read-file-for-loop-628347/)

mogra 03-15-2008 09:05 PM

Reg Makefile : Read file : for loop
 
I have following code in my

make file :

Code:

batch.txt:
        rm -f $@ ;
        for file in $(wildcard t*_diff.txt); do \
                        echo "$${file}        1        2        $${file}        0" >> $@ ; \
        done ;

My goal is to modify this code,

a) it should read in the file "ids.txt" : which will have all the different file ids, for each id in the file it should

do echo "$${file} 1 2 $${file} 0" >> $@ ; \



Making short instead of *.diff.txt now I want to read in the file which has all the ids. I don't know how read in file in Makefiles into array ..

Thanks a lot.

simplicissimus 03-16-2008 07:27 AM

using backticks in Makefile
 
My solution would go like this:

Code:

ABCFILE=`cat abcfile`
batch.txt:
        rm -f $@ ;
        for file in $(ABCFILE); do \
        echo "$${file}        1        2        $${file}        0" >> $@ ; \
        done ;

My input file named 'abcfile' simply contains the line 'a b c' where everything between whitespaces will become a token. The new 'batch.txt' output looks like this:

Code:

a        1        2        a        0
b        1        2        b        0
c        1        2        c        0

Is this what you wanted to achieve?

Hope this helps,
Regards,
SIMP

Linux Archive

mogra 03-16-2008 12:57 PM

Thanks
 
Thanks a lot.

The original Makefile is big, but yeap for this snippet of code thats what I wanted.

Thanks a lot.


-mogra


All times are GMT -5. The time now is 06:40 AM.