Well , i have:
$ cat example.dat
1
2
3
4
5
$ cat getline3.awk
function getName (NOM)
{
printf "Enter a filename: "
getline NOM < "-" # get response
return NOM
}
BEGIN {
printf ("\nREP: %s\n",getName(N))
}
{print}
This example works fine:
$ awk -f getline3.awk example.dat
Enter a filename: EXAMPLE
REP: EXAMPLE
1
2
3
4
5
But this one fails because the script does not stop to get the filename (it took the first line of the example.dat file)
$ awk -f getline3.awk <example.dat
Enter a filename:
REP: 1
2
3
4
5
Any ideas to solve the problem??
Thx in advance