I know ARGV[i]
can be used for storing user input. However, I want to use it in awk script and get the ARGV[i]
to compare the field from another text file. If the ARGV[i]
matches the field or the field contains ARGV[i]
which is the user input, then I want to return the other fields of that line.
Let say I have a file, testing.txt
:
123123123:Walter White:1:2:3:4
123123124:Jesse Pinkman:1:3:4:1
This is my awk script, awkScript.awk
:
#!/usr/bin/awk -f
BEGIN{FS = ":"; print "ENTER A NAME: "}
{
for (i = 1; i < ARGC; i++)
{
if ($2 ~ /'ARGV[i]'/)
{
print "Member ID: " $1
}
}
}
It just prints ENTER A NAME: when I execute the script file. It doesn't even get the input from the user.
testing.txt
? how do you think awk will get user input ? – Archemar Oct 19 '14 at 9:38