Hi everybody! I've been trying to figure this out for the past couple of days and I'm stumped...
I am trying to input from a file. The file's layout has three columns; a department number, a first name and a last name, each separated by a space, for example:
Code:
781-89-4271 Amy Balduff
839-98-4072 Brian Becker
846-43-4284 Christina Brendon
894-45-8694 Christine Cardosa-Ramirez
920-57-4251 Cindy Chen
469-55-6165 Corinna Deitz
466-54-3764 Cynth Dominguez
736-19-7345 Daniel Eversole
870-38-1858 David Flucker
539-71-2357 Dinno Gordillo
344-94-6979 Emily Hendrickson
532-37-4293 Gregory Herrera
916-86-6635 Heidi Hoang
614-90-6031 Hsu-Chia Houg
721-15-6603 Jack Jacobs
899-77-6019 Jamie Kim
671-12-5143 Jeffrey Koras
361-11-4712 Joseph Lewis
926-34-2055 Kurt Mananquil
885-66-4875 Leandra Martin
472-91-4771 Naomi Melick
663-25-1407 Omar Peralta
370-16-4687 Patricia Pesulima
207-82-3872 Robert Peters
743-92-4767 Rochelle Phang
962-92-4730 Salisha Salgado
587-95-1967 Savoeun Sanchez
758-12-8821 Shelley Siegel
479-65-3842 Stephanie Villarreal
644-86-6117 Thomas Williams
this is what I have so far:
Code:
#!/bin/bash
#
#adds user from a text format:
file=${1}
for i in $(cat $file);
do
dept=$(echo $i | cut -d" " -f1)
fname=$(echo $i | cut -d" " -f2)
lname=$(echo $i | cut -d" " -f3)
echo $fname $lname $dept
done
The output that I get is like this :
781-89-4271 781-89-4271 781-89-4271
Amy Amy Amy
Baldruff Baldruff Baldruff
instead of :
781-89-4271 Amy Baldruff
I need to input the words through separate variables because I will be passing them to other programs as soon as I can figure this out.
Any help??