Re: Solution solicited
Posted in 1996
In article <52omsp$fp1@cssun.mathcs.emory.edu>, ukantjx@lexis-nexis.com (Jamini Kant) writes: > I have a problem in writing a shell program . Any suggestion/solution > is most welcome. > > I have a make file like > ------------------------- > > #LOADLIBS This contains the list of libraries > LOADLIB := /a/b/lib1 a/b/lib2 \\ > /a/c/lib3 \\ > /a/d/lib4 > > #INCDIR This had a list of all INCDIR files in it. > INCDIR := x/y/incdir1 /x/a/incdir2 \\ > /y/d/incdir3 \\ > /z/g/incdir4 > > #USES is the dependent etc ..... > --------------------------------- > The following is the portion of the shell script > which gives the listing of all INCDIRs. But the prob > is it does not list the listing in the next line. > For example in the above example for INCDIR > it prints only "x/y/incdir1" and "/x/a/incdir2" > but ignores to print other INCDIRs in the next line. > > > echo $line > echo 'LIBRARY USED LIBRARY LOADED INCDIRS' > echo $line > > #for INCDIRS > for list in `grep INCDIRS Makefile | grep -v '#' | cut -d= -f2 |grep " \\"` > do > echo " $list" > done Instead of grep use awk awk 'In==1;/^INCDIR/ { In=1;print $3 " " $4 } ;!/\\\\$/{In=0}' Makefile | while read line;do for i in $line;do [ -n "$i" ] && echo " $i" done done The bit with [ -n "$i" ] && echo is because i can be empty for some reason. ---------------------------------------------------------------------- David Paulo, InForm Group Ltd.,PO Box 1444, Wellington, New Zealand. Ph: +64 4 472 0996 Fax: +64 4 473 2407 Email: david@inform.co.nz = What would you do if you knew that you could not fail = ----------------------------------------------------------------------