RE: ** OT : awk works only for first line

  • From: A Joshi <ajoshi977@xxxxxxxxx>
  • To: "oracle-l@xxxxxxxxxxxxx" <oracle-l@xxxxxxxxxxxxx>, Mark.Bobak@xxxxxxxxxxxx
  • Date: Tue, 27 Jan 2009 18:48:42 -0800 (PST)

Mark,

   Here is the full code and full file : 



$cat emp_lis.sh

emp_sal=`cat emp_1`

for f1 in $emp_sal

  do 

    emp_name=`echo $f1 |awk -f emp.awk`

    echo $emp_name

  done



$cat emp.awk   

BEGIN {

  FS=":"

}

{print $1}

$cat emp_1     

------- 

john_ray:8743943

joe_smith:  2134093

bill_bates:  3243243

jane_de: 9843243

$. ./emp_lis.sh

-------

john_ray

joe_smith

2134093

bill_bates

3243243

jane_de

9843243

$





--- On Tue, 1/27/09, Bobak, Mark <Mark.Bobak@xxxxxxxxxxxx> wrote:
From: Bobak, Mark <Mark.Bobak@xxxxxxxxxxxx>
Subject: RE: ** OT : awk works only for first line
To: "ajoshi977@xxxxxxxxx" <ajoshi977@xxxxxxxxx>, "oracle-l@xxxxxxxxxxxxx" 
<oracle-l@xxxxxxxxxxxxx>
Date: Tuesday, January 27, 2009, 8:15 PM

Can you show a small sample of your data, one line that works correctly, and one
or more that don't work correctly?

-Mark
________________________________________
From: oracle-l-bounce@xxxxxxxxxxxxx [oracle-l-bounce@xxxxxxxxxxxxx] On Behalf
Of A Joshi [ajoshi977@xxxxxxxxx]
Sent: Tuesday, January 27, 2009 7:25 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: ** OT : awk works only for first line

Hi,
I am trying awk to get the first word from each line in a file : I am doing :
BEGIN {
FS=":"
}
{print $1}

For the first line : it prints the first work. For other lines it prints other
words also. I tried to put in FS as space but that did not help. Can someone
help? I did try google but could only find example like above. Thanks for help.



--
//www.freelists.org/webpage/oracle-l





      

Other related posts: