Example of a program using 'awk'.


This easy awk program generates an rpv file containing the current environment for Unix.

BEGIN {FS = "="

print "report_title=unix environment (example with awk)"
print "$1=400"
print "$2=4000"
print "[header]"
print "{f=arial;s=10}"
print "{spacing=600;\\n}"
print "{b=y;u=y;$1} Variable {$2} Value {b=n;u=n;\\n;\\n}"
print "[data]"}
{

print "{$1} " $1 " {$2}= " $2 "{\\n}"

}

Please observe that newline (\n) has two backslashes. Remember that we're working in Unix.

How to run this

1.- Just place this program and name it with anyname.awk

2.- Execute the following command at the prompt:

# set | awk -f anyname.awk > /tmp/rpvqueue/settings.rpv

Please note that the output of awk is a file placed in /tmp/rpvqueue. That will be the queue directory and the server must be active and searching there.

Something better you can do.

# set | awk -f anyname.awk > settings.rpv;mv settings.rpv /tmp/rpvqueue

In this case we're generating the file first and after that we're moving it to the queue directory. This would be the proper way.