Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site cbnap.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!dual!qantel!ihnp4!cbosgd!cbdkc1!cbnap!whp From: whp@cbnap.UUCP (W. H. Pollock x4575 3S235) Newsgroups: net.unix-wizards Subject: Re: AWK question Message-ID: <36@cbnap.UUCP> Date: Fri, 9-Aug-85 14:05:02 EDT Article-I.D.: cbnap.36 Posted: Fri Aug 9 14:05:02 1985 Date-Received: Tue, 13-Aug-85 00:46:16 EDT References: <435@brl-tgr.ARPA> <855@turtlevax.UUCP> Reply-To: whp@cbnap.UUCP (W. H. Pollock x4575 3S235) Organization: AT&T Bell Laboratories, Columbus Lines: 31 >>Does anyone know if and how I can get awk to do a >= (less than or equal) >>on a value entered from a terminal by the user? >>E.G. >>echo 'enter date in format yy-mm-dd \c $dt' >>read dt >>echo $dt >>awk '$5 >= $dt ' .suspfile >xout > >Have you tried using double quotes instead of single quotes? Try: > awk "$5 >= $dt " .suspfile >xout Wrongo! This won't work since the shell will substitute for the $5 as well! A more correct version is: awk '$5 >= '$dt .suspfile >xout The spacing around the quotes is critical. Also, you may have a problem if awk thinks $5 is a string and $dt is a number (or vice versa). To force numeric comparision, use: awk '$5 + 0 >= '$dt' + 0' .suspfile >xout To force string comparision, use: awk '$5 "" >= '$dt' ""' .suspfile >xout It is possible to set an awk variable on the command line, and avoid fooling with the quotes. Wayne Pollock PS why don't you use sed (or cut) and test instead?