Re: awk 2 variables from a single range?

From: avidfan (none_at_swbell.net)
Date: 10/28/04


Date: Thu, 28 Oct 2004 13:21:49 GMT


"Stephane CHAZELAS" <this.address@is.invalid> wrote in message
news:slrnco14hm.15o.stephane.chazelas@spam.is.invalid...
> 2004-10-28, 06:15(+00), AvidFan:
> > If, in ksh, I prompt the user for a range, in the format 1-255, and I
use
> > the read command to accept that as a single variable, how can I use awk
to
> > split that into 2 variables? I can't seem to figure out how to use a
> > variable as input for awk, so that it can split it into two variables...
> [...]
>
> Why would you want to use awk? read is the perfect tool for
> that:
>
> IFS=" -" read min max junk
>
> To use a variable as input for awk:
>
> awk 'BEGIN{print ARGV[1]; exit}' "$var"
>
> (use /usr/xpg4/bin/awk on Solaris).
>
> --
> Stephane

That works perfectly and with much less confusion. Thank you!

AvidFan



Relevant Pages

  • Re: Removing lines from a plain text file
    ... Apparently there is no simple command. ... > and put prune in a cron job. ... > size by removing the excess from the beginning of the file. ... date from the past and use awk to search through the file for it and discard ...
    (comp.unix.sco.misc)
  • Re: Closing a field
    ... I thought of the same solution, that of using the field number count as the discriminant, mainly because I don't have any idea how to use AWK to validate a field as a number. ... The treatment of tabs as an alias for spaces in some POSIX is motivating me to stay away from them. ... already have a filter called 'join' so why not use AWK to create a filter called 'select' and for other SQL commands as well. ... I'd want to call the script by its SQL command name and use it as an SQL-like Unix pipe filter. ...
    (comp.lang.awk)
  • Re: Problem while executing "system " in awk
    ... There is a file(named myno) containg phone numbers. ... I've written following awk prog ... Please suggest why my systemcommand is not executing ... it is possible that the shell is seeing your command as ...
    (comp.lang.awk)
  • Re: Newbie Scripting Variable Question
    ... A lot of scripters use the single back quotes to indicate a command ... The cal is evauated, the output used as input for awk, and then the awk ... is the Korn Shell by David Korn. ... # typeset -Z2 abc ...
    (comp.unix.aix)
  • Re: Interesting math
    ... One thing I've learned is that it's often a superior language for ... And if you want to do build up a command line, ... Write the script in Perl instead, and all these problems just go away. ... anything you could do from a C program, or an awk program for that matter. ...
    (alt.usage.english)