LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-15-2008, 09:05 PM   #1
mogra
LQ Newbie
 
Registered: Mar 2008
Posts: 4

Rep: Reputation: 0
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.
 
Old 03-16-2008, 07:27 AM   #2
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
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

Last edited by simplicissimus; 04-02-2008 at 04:34 AM.
 
Old 03-16-2008, 12:57 PM   #3
mogra
LQ Newbie
 
Registered: Mar 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks

Thanks a lot.

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

Thanks a lot.


-mogra

Last edited by mogra; 03-16-2008 at 01:08 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: Read entire file line in for loop clinton Programming 16 04-18-2013 12:06 PM
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 8 04-05-2011 09:18 AM
Makefile issue: "Makefile.src: File not found" m3rkury Linux - Software 1 02-22-2007 10:15 PM
while READ loop problem caps_phisto Linux - General 3 02-05-2007 09:58 AM
reg loop back adapater anilchow Linux - Security 1 10-02-2003 06:01 AM


All times are GMT -5. The time now is 07:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration