I have two files.
file1.txt contains:
META GAIN CORP
GG$
ABG$
PEPRA_UAT
12GHR
CC$
USDP_MAIN
XQ$
PR$
MIX_DEV
and file2.csv contains:
\\fr.usdp.org\SOLE\Home\RD,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\99 FLOOR,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\44 FLOOR,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\META GAIN CORP,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\META GAIN CORP,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\META GAIN CORP,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\META GAIN CORP,[email protected]
\\fr.usdp.org\SOLE\Shares\FR\USDP WATER\ABG$,[email protected]
\\fr.usdp.org\SOLE\Shares\FR\USDP WATER\ABG$,[email protected]
\\fr.usdp.org\SOLE\Shares\FR\USDP WATER\ABG$,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\HHR DATABASE,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\HHR DB2 EDU,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\HHR DB2 EDU,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\NICE SHORT,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\PRO DEV,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\DUK 20154 USER,
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\DUK 20154 USER,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\FARE GRUST,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\XYZ GROUP,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\XYZ TEAM TOOLKIT,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\BILLING ELEMENT,[email protected]
\\fr.usdp.org\SOLE\SHARES\FR\USDP WATER\RRT_SEC,[email protected]
had this on my script but I can't exactly get the last column if there are spaces.
for sr in `cat file1.txt`; do
sname=`echo ${sr} | awk -F: '{ print $1 }'`
emdrs=`grep -Fw "${sname}" file2.csv | awk -F',' '{print$2}' | sed 's/[[:space:]]//' | xargs | sed -e 's/ /,/g'`
echo "$sname || To: $emdrs" >> details.txt
done
details.txt output
META || [email protected],[email protected],[email protected],[email protected]
GAIN || [email protected],[email protected],[email protected],[email protected]
CORP || [email protected],[email protected],[email protected],[email protected]
but what i wanted is that
META GAIN CORP || To: [email protected],[email protected],[email protected],[email protected]
and I should also be able to search string with $ like this one ABG$ ) and not including the duplicate email.
ABG$ || To: [email protected],[email protected]
Any help will be greatly appreciated.