1|abc mail|mail subject|mail body
2|def mail|mail subject|def mail body
I am trying to read the variables from data_1.out and use them to print to 2 different files based on the id (first_column)
The problem is I am not able to read the file using FS in the nawk. Could some help me out. If I substitute the "|" with space in data_1.out below thing works.
You don't need awk at all here, or wc, or expr, or backticks. You can do this all in one while read loop.
while IFS="|" read ID MAIL_ID MAIL_SUBJECT MAIL_BODY
do
cat <<EOF >> m_file_${ID}.out
From: abc@unix.com
To: ${MAIL_ID}
Subject: IDI : ${MAIL_SUBJECT}
${MAIL_BODY}
EOF
done