I haveusers.txt
as input file like below format.
rajesh.kumar@company.com
rhmn@company.com
mkkumar@company.com
manish.panday@company.com
daniel.m@company.com
jain@company.com
abul@company.com
aditi@company.com
aditya.s@company.com
Below script to read the users.txt
file line by line and write only the matching user mail address along with row into the csv file.
#!/bin/bash
Input_file="users.txt"
Output_file="result.csv"
Match_list="$(command_to_get_match_user)"
Email="$(echo "$Match_list" | awk -F '|' '{print $4}' | tr -d '[:space:]')"
while read line; do
if [[ "$line" == *"$Email"* ]]; then
echo "$line" >> "$Output_file"
fi
done < "$Input_file"
My command Match_list=
in the above script provides the below output during the run time.
1320 | | Rajesh Kumar | rajesh.kumar@company.com | live
1584 | | A.K.M. Rahman | rhmn@company.com | live
1503 | | Mukesh Kumar | mkkumar@company.com | live
1279 | | Aayush Jain | aayush.jain@company.com | live
1597 | | Abul Hasan Md Osama | abul.osama@company.com | live
1660 | | Aditi Singpuri | aditi.singpuri@company.com | live
1570 | | Aditya Jain | aditya.jain@company.com | live
Currently above script is not writing the matched result in to file.
What is wrong with my code?