Date: Wed, 29 Aug 2001 18:14:15 +0200 From: Stijn Hoop <stijn@win.tue.nl> To: Odhiambo Washington <wash@wananchi.com> Cc: Giorgos Keramidas <keramida@ceid.upatras.gr>, FBSD-Q <freebsd-questions@freebsd.org> Subject: Re: another easy one for the script gurus Message-ID: <20010829181415.B21660@pcwin002.win.tue.nl> In-Reply-To: <20010829180839.F7356@ns2.wananchi.com>; from wash@wananchi.com on Wed, Aug 29, 2001 at 06:08:39PM %2B0300 References: <20010828191422.P14463@ns2.wananchi.com> <20010828233939.A12493@hades.hell.gr> <20010829180839.F7356@ns2.wananchi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 29, 2001 at 06:08:39PM +0300, Odhiambo Washington wrote: > | > | You want in your Makefile something along the lines of: > | > | somefilename: > | awk -F: '{print $$1,$$2}' < /etc/master.passwd > $@ > | > > ## > authtab: > cat master.passwd.test | awk -F ":" '{if ($3>999) {print $1":"$2}}' > ## > In all that I expect it to generate the file called authtab. > > If I try your redirects (BTW what does $@ represent?) It generates errors > > alligator# make > awk -F ":" '{if (>999) {print ":"}}' < master.passwd.test > authtab > awk: cmd. line:1: {if (>999) {print ":"}} > awk: cmd. line:1: ^ syntax error > *** Error code 1 > Stop in /etc/Exim. > > I don't get where the $3 disappears to. make also interprets variables, and those always happen to start with a '$' by convention. make reads your line as having the variable $3 in it which isn't defined, so it has the value ''. You need to double the $'s for make to not interpret them. Also, having a target doesn't instruct make to automatically create a file named like that; you have to explicitly redirect the output from awk to a file named 'authtab', or to $@ which is a make variable meaning 'the name of the current target'. Something like this should work better: authtab: umask 077; cat master.passwd.test | \ awk -F ":" '{if ($$3>999) {print $$1":"$$2}}' > $@ (Giorgios also posted a version of this above). --Stijn -- Tact, n.: The unsaid part of what you're thinking. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010829181415.B21660>