Hi all,
Can you please help me to find out that where is the problem in my script or either my way of writing the shell command on the prompt is not right? Actually, I want to compare the second column "$1" of the file "t1" with all the columns of second file "t2", if there is a match then the script should return the matched column. But currently my script is printing the whole data of the first file "t1". I will highly appreciate any feedback and suggestions. I badly need to fix this problem as soon as possible; therefore any quick response will be acknowledged.
File1 "t1":
7 real_name
8 pa_name
9 make_server_info_pw
9 passon
11 mapped_name
11 nt_status
13 passon
15 p
17 server_info
18 p
File2 "t2":
1 CHECK_DECLS
1 True
1 conf
1 headers
1 reverse
1 real_name
Script:
#!/usr/bin/awk
BEGIN {
FS= � �;
OFS=� �;
RS= �\n�;
ORS=�\n�;
}
NR==FNR
{
arr[$1]; next
}
$1 in arr {
print $1;
} file1 file2
Shell command to execute the script
awk -f sim.awk t1 t2
Desired out put
real_name