I wrote this small bash script, i want to compare second column from file1 with file2 if a pattern matches. Files are small and I am sure that pattern occurs only once. I think this can be rewritten into a awk one liner. Appreciate if someone could give me idea. Whole NR FNR confuse me :o
#!/bin/bash
var1=$(awk '/pattern/ { print $2 }' file1)
var2=$(awk '/pattern/ { print $2 }' file2)
if [[ "${var1}" != "${var2}" ]];then
echo "Second column is not matching"
fi
Probably slow because of the disk access and if it's too big, then diff may also struggle.
Not the best, but a clunky way to be sure it will actually work. Perhaps this will give you a good basis to see what output from a better (more efficient) process should be.