Thanks for the reply but this does not work, I need awk (or nawk) to read a file that contains lines, the user is then shown the line and should enter Y to select it or N to skip. If they select Y it should be written into another file or variable for use later in the script.
Thanks, that is better, but still having problems as it displays all lines from myInputFile without prompting. With system("read") I get the prompts but input is ignored?
function promptMe(myLine, yn)
{
printf("Select [%s] (Y/N): ", myLine)
cmd="read a; echo $a"
cmd | getline yn
close(cmd)
return tolower(yn)
}
{
if (promptMe($0) == "y")
print "do the YES thingy with line [$0]"
else
print "do the NO thingy with line [$0]"
}
sorry - wrong format of the 'print' statement.
the content of the '$0' is the same as the 'myLine'
function promptMe(myLine, yn)
{
printf("Select [%s] (Y/N): ", myLine)
cmd="read a; echo $a"
cmd | getline yn
close(cmd)
return tolower(yn)
}
{
if (promptMe($0) == "y")
print "do the YES thingy with line [" $0 "]"
else
print "do the NO thingy with line [" $0 "]"
}