Welcome to the Linux Foundation Forum!

Read file content with while and awk combined

Hi all,
I have a text file with the following content

Baluta, Mircea (M.C.) mbaluta@yahoo.com; Ica, Victor Stefanita (V.I.) vica@yahoo.com; Badea
, Alexandra Nicoleta (A.B.) abadea6@yahoo.com>; Paun, Wily Robert (W.C.) WPAUN1@yahoo.com; S
toica, Bogdan (B.S.) BSTOICA1@yahoo.com; Mitroi, Ilie (I.M.) imitroi@yahoo.com; Pirvu, Ion-Cri
stian (C.P.) cpirvu@yahoo.com; Mihutoiu, Marius (M.M.) mmihutoi@yahoo.com; Ghita, Nuta (N.G.) ng
hita@yahoo.com; Vais, Marcel (M.V.) mvais@yahoo.com; Dinuleasa, Marin-Catalin (M.D.) MDINULE
A@yahoo.com; Sutiman, Amado Laviniu (A.S.) asutiman@yahoo.com; Ruiu, Marius-Sorin (M. S.) mr
uiu@yahoo.com; Ivascu, Aurica (A. I.) aivascu@yahoo.com; Toma, Valter-Florian (V.T.) vtoma1@
yahoo.com; Siuinea, Ileana-Gabriela (I.S.) isiuinea@yahoo.com; Minca, Angelica Doina (A. D.)
aminca@yahoo.com; Till, Aurica-Marian (A.T.) atill2@yahoo.com; Fiera, Mariana (M.F.) mfiera@f
ord.com; Mozoc, Vasile (V.S.) vmozoc@yahoo.com; Tuca, Alexandru gabriel (A.T.) ATUCA@yahoo.c
om; Radu, Adrian (A.R.) aradu2@yahoo.com; Mihaescu, Victor (V.M.) vmihaesc@yahoo.com; Ghita, D
orin (D. A.) dghita@yahoo.com; Ardeleanu-Trusca, Daniel (D.A.) dardelea@yahoo.com; Marin, Ma
rius (M. G.) mmarin12@yahoo.com;

So every field is of form FirstName, LastName (M.C.) user@yahoo.com;
I want to display only user for all the users in the file

FILENAME="/home/ubuntu/user01.txt"
while reading LINES
do
echo $LINES | awk -F "@" '{print $1}' | awk '{print $NF}'
done < $FILENAME

So finally, as an example, the script only displays mbaluta for the user Baluta, Mircea (M.C.) mbaluta@ford.com; and I would like to display it for everyone
Do you have any suggestions?

Categories

Upcoming Training