The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-21-2004
bcheaib bcheaib is offline
Registered User
  
 

Join Date: Jul 2004
Location: Beirut
Posts: 25
passing awk variable to the shell script

hi;

i have a file containing lines like:

1|1069108123|96393669788|00963215755711|2|0|941||;serv:Pps6aSyria;first:0;bear

i want to extract the second, third and fourth record of each line and store it in a file ";" seperated

this is what i wrote

while read line
do
A_party=`echo $line |awk -F["|"] '{print $3}'`
B_party=`echo $line |awk -F["|"] '{print $4}'`
time=`echo $line |awk -F["|"] '{print $2}'`

echo $A_party";"$B_party";"$time >> $_outfile
done < $_infile

But the problem is that i am calling three times awk for each line, how can i pass awk variable to the script in order to call awk only one time.

Thanks in advance.