I have another file
cat supplierDetails.txt
-------------------------
112|MIMUS|krishnaveni@google.com
113|MIMIRE|krishnaveni@google.com
114|MIMCHN|krishnaveni@google.com
115|CEL|krishnaveni@google.com
108|UGEN|krishnaveni@google.com
109|SLAND|krishnaveni@google.com
I need to compare above values to this file first column values
like
if 112=112 then
i need to print MIMUS
like i need to validate above all values to this file,
I need it in loop
Your error was most likely using a dollar sign $tempfile when the name of the file was just tempfile (at least in the example Shivdatta posted)
... Though, in fact you don't need a temporary file at all:
while read val
do
awk -F"|" -v val="$val" '$0 ~ val{print $1,$2}' supplierList.txt
done <file1 | mailx -s "Gateway messaging:" -r krish@google.com
I cleaned up some other various crimes against humanity in that script (grep | awk, cat in backticks), some of my fixes might not work if you are on HP-UX or some other severely crippled platform; change them back if so.
THis script works fine,
awk -F"|" 'NR==FNR{arr[$0];next}$1 in arr{print $2;system("mail -s "$2" "$3"<<EOF")}' file1.txt supplierList.txt
here no need of file1.txt file, i dont have list of values to validate
i have only one value need to validate
val=112, then i need to look into supplierList.txt file
then
subject:MIMUS and mail to krish@google.com
Please suggest me and help me. Its very urgent waiting for reply