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 03-19-2009
sunpraveen's Avatar
sunpraveen sunpraveen is offline
Registered User
  
 

Join Date: Jan 2009
Location: Pruthvi
Posts: 85
Question Unable to assign value to variable using awk coz of whitespace in value

Unix gurus,

I have a file as below, which is basically the result set obtained from a sql query on an Oracle database.


Code:
ID           PROG_NAME      USER_PROG_NAME
-------- --------------- ----------------------------------------
33045      INCOIN             Import Items
42690      POXPOPDOI       Import Standard Purchase Orders

I want to assign the results to variables. Something like:


Code:

cat filename | tail +4 | while read line ## tail +4 because the first 3 lines are the heading!
do
id=$(echo ${line} | awk '{print $1}')
prog_name=$(echo ${line} | awk '{print $2}')
user_prog_name=$(echo ${line} | awk '{print $3}')



However, I am unable to assign the 3rd column to variable user_prog_name since it has spaces.

How can I overcome this problem?

TIA,

Regards,

Praveen