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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Awk variable query

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
Is it possible to create an output file variable in awk, as in shell scripting, of the type:

DAT=`date +%d%m%y`
OUTFILE="/tmp/text."DAT

Thereby allowing data to be directed to $OUTFILE
 
as in:

Code:
# cat /tmp/testfile
cat: 0652-050 Cannot open /tmp/testfile.
# echo this should be in testfile|awk '{file="/tmp/" $NF; print >file}'
# cat /tmp/testfile
this should be in testfile


HTH,

p5wizard
 
In the man awk page pay attention to the getline fuction

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top