The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-16-2008
anhtt anhtt is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 22
global variable in awk

I wrote a awk script file and define some global variables after BEGIN option:
BEGIN {
cell = "";
alarm = "";}

when i run the command:
awk -f awk_script inputfile
The results are as expected. But when I put awk script into a shell script. Global variables couldn't be understand.

I don't want to use the formatting:
awk -v cell=123 awk_script inputfile . Because the global variables can't be changed many times before finishing awk_script ( with -v option: golbal variables're alway fixed).

Who can solve this for us?
Thanks