I need to input data from the keyboard in awk.The only
reference I can find in any of my AWK books is
to do the following:
BEGIN { printf "Enter your name: "
getline name < "-"
print name
}
This was accompanied by the footnote that not all
versions of awk/nawk/gawk/etc. support the use of
"-" with getline to read from the standard input.
I am using UNIX on a Sun system, and < "-" does
not work.
I tried using the following:
printf "Enter your name: "
system("read" | getline name
This stops program flow and allows you to type in
data, but I cannot get the inputted data into an
awk variable, in this case name.
Any ideas?
reference I can find in any of my AWK books is
to do the following:
BEGIN { printf "Enter your name: "
getline name < "-"
print name
}
This was accompanied by the footnote that not all
versions of awk/nawk/gawk/etc. support the use of
"-" with getline to read from the standard input.
I am using UNIX on a Sun system, and < "-" does
not work.
I tried using the following:
printf "Enter your name: "
system("read" | getline name
This stops program flow and allows you to type in
data, but I cannot get the inputted data into an
awk variable, in this case name.
Any ideas?