I don't think your desired output is compliant with your input data, and it has duplicate values in it. So it was difficult to implement sth fitting to your specification.
Anyhow, try
awk '
NR==FNR {T[$1]
next
}
/SCHEDULE/ {SCHEDNAM=$2}
$1 in T {print $1, SCHEDNAM
delete T[$1]
}
END {for (t in T) print t, "not in file1"
}
' file2 file1
WS1#JOB1 WS1#JS1
WS2#JOB1 WS2#JS1
WS3#JOB4 not in file1
The script is working with the example that i had given, but when i try this with a big file, the script doesnt seem to work. I am getting not in file1 for all the data in file2.
On first sight, I can't see a match between lines in "other file" and "big file". How do you expect anyone to compose some code when it can't be seriously tested against meaningful samples?
This is my IMMEDIATE result running my unmodified proposal against your samples:
A01G3GBOAPP1A#J01AQMSPSR2PWEB A01G3GBOAPP1A#J01AQMSPBATCH01
A01G3GBOAPP1A#J01AQMSPEMAILIN A01G3GBOAPP1A#J01AQMSPBATCH02
A01G3GWPAPP1A#J01G3GPND2R007 not in file1
That is working fine. the issue was with my file1 which is not in the correct format. When i print $2, it leaves the first 3 characters and fetches the remaining lines.
that was the reason i for not available for all the records in file1. Extracted the file again and got this done.