I have awk
script doing some processing and sending it\'s output to a file.
How would I writeout in BEGIN block of my awk
program a banner-like mes
Is this some that you look for?
var="Peter Hanson"
awk -v auth="$var" '
BEGIN {print "#########################################"
print "# generated by some author #"
printf "#";
l=int((41-length(auth))/2)
r=((41-length(auth))/2-l)*2
for (i=1;i<=l;i++)
printf " "
printf "%s",auth
for (i=1;i<=l+r-2;i++)
printf " "
print "#"
print "#########################################"
}' file
#########################################
# generated by some author #
# Peter Hanson #
#########################################
This will take the data in the variable var
and print it as the second line.
It does adjust the field with, so it its centered.
You need to enter your code for the rest after the last print