06-17-04 10:55 PM
rgaffuri@cox.net (Ryan Gaffuri) wrote in message news:<1efdad5b.0406160612.6f3aa12b@posting.
google.com>...
> Not sure if this got posted already, if so please ignore...
>
> I want to pass a variable to represent the column I want to 'cut', the
> following returns the whole line.
>
> CUT_FIELD=2
> RETURN_VALUE=`grep ^${GREP_NAME} $FILE_NAME|cut -f${CUT_FIELD} -
d:`
>
> DATA:
> GREP_NAME HELLO GOODBYE 1
>
> In this case, I only want to return "GOODBYE", however, I in the
> future I may want to return "HELLO" or "1"
why are you delimiting by comma?
awk maybe easier....try piping it though awk \{print\$$CUT_FIELD\}
[ Post a follow-up to this message ]
|