Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling awk in a ksh script - passing values to and fro 1

Status
Not open for further replies.

ribeye

IS-IT--Management
Feb 25, 2005
1
US
I have a script that will pipe a parm to awk.&nbsp;&nbsp;Within awk, the parm is parsed.&nbsp;&nbsp;How do I access the variable within the awk {...} part of the script outside of the awk {...} part.&nbsp;&nbsp;Here's an example...<br><br>#ksh shell script stuff here...<br>.<br>.<br>.<br>$1¦ awk '<br>{<br>len = length($0)<br>parsed_parm = substr($0, len - 5 + 1)<br>}'<br>.<br>.<br>.<br>#more ksh shell script stuff here<br><br><br>How do I access parsed_parm outside the awk part?&nbsp;&nbsp;Please reply to <A HREF="mailto:t_monaghan@yahoo.com">t_monaghan@yahoo.com</A>.&nbsp;&nbsp;Thanks!!!!
 
This should provide one way to do this:<br><br>pparm=`awk '{<br>&nbsp;&nbsp;&nbsp;&nbsp;len = length($0)<br>&nbsp;&nbsp;&nbsp;&nbsp;parsed_parm = substr($0, len - 5 + 1)<br>}' $1`<br><br>echo $pparm<br><br> <p>flogrr<br><a href=mailto:flogr@yahoo.com>flogr@yahoo.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top