passw awk variable to shell script



Sorry guys not specifically solaris related but i cant find any info
ANYwhere about this.

I want to set a shell variable in a script but with awk.

I can find so many pages about setting awk variables with shell variables

e.g

BasePatch=115275-12
EPatchRev=`nawk '/^Patch: '"$BasePatch"'/ {print $2}'


BUT i want to set a shell variable with the $2 or $1 from an awk print
statement.

I have tried this which i saw somewhere but it doesnt work.

echo $line | awk -F- '{ system( "BasePatch=" $1 ) ; system( "Rev=" $2 )}'

Im wanting to set vairable BasePatch and Rev in the shell script in one
awk line.

Thanks
_______________________________________________
sunmanagers mailing list
sunmanagers@xxxxxxxxxxxxxxx
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



Relevant Pages

  • Re: for loop (?)
    ... you should use awk variables in awk scripts instead ... > of shell variables to avoid problems when those shell variables include ... can handle NUL characters correctly in its input. ... pass these characters to the script in the first place. ...
    (comp.unix.shell)
  • Re: for loop (?)
    ... you should use awk variables in awk scripts instead ... >>of shell variables to avoid problems when those shell variables include ... I doubt if I've ever written a shell script that's robust ... > extra effort to make the script robust against weird inputs. ...
    (comp.unix.shell)
  • Re: split string in sh
    ... structure (to awk) in there, but I'm just trying to make it look like your shell ... I tried "$name1" and $name1 and those didn't work. ... to init the awk variables name1 and name2 to the value of the shell variables ...
    (comp.unix.shell)
  • Re: awk problem
    ... I am processing these and another set of records using a shell script. ... awk is not shell. ... Just like you can't use shell variables in your C programs, you can't use shell variables in your awk programs. ... It should be noted that an exact match for the course code is required, ...
    (comp.lang.awk)
  • Re: how to make value of two variables available shell <==> awk?
    ... 21 printf "stemp should be same as error_block.txt entries $stemp\n" ... What you're probably referring to is not what you've written above, but is instead the really bad idea of jumping in and out of awk by means of carving up the script with spurious single quotes. ... You CANNOT access shell variables inside awk programs any more than you can access shell variables inside C programs. ...
    (comp.unix.shell)