Above is the sample file, I would like to check if "field5" exists in file, if exists check if 67890 exits, if exists then print corresponding values for "field5"
112 is actually the seventh field - assuming the pipe symbols are field delimiters.
This works with your sample, which does not necessarily match what you describe.
It prints the last field on the 67890 line (where 67890 is the first field) -- if the line exists.
if [ grep -q "field5" somefilename ] ; then # check for field5
grep -q '^67890' somefilename && awk '{print $(NF) } ' || echo ' 67890 not found'
else
echo 'not found' # field5 is not found
fi
This is not very good code but your description kind of limits what I can show you.