If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > assigning the value to variables from file

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-10, 15:39
vineelaregonda vineelaregonda is offline
Registered User
 
Join Date: May 2009
Posts: 43
assigning the value to variables from file

Hi,

My file with the name "ouput" has a text like

"Adaptive Server Enterprise/15.0.2/EBF 15777 ESD#2 ONE-OFF/P/Sun_svr4/OS 5.8/ase"

I need to assign "15.0.2" value to one variable and "EBF 15777 ESD#2 ONE-OFF" to another variable.


I am able to print the two words as follows

awk '{FS="/"}{print $2, $3}' output
15.0.2 EBF 15777 ESD#2 ONE-OFF

If I pass this output to a different file, then EBF, 15777 ESD#2 ...each acts like single word.

My requirement is like
a="15.0.2"
b="EBF 15777 ESD#2 ONE-OFF"

please help me to resolve this issue.

Thanks,
Vineela
Reply With Quote
  #2 (permalink)  
Old 01-11-10, 16:05
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
Something like this should be ok
Code:
var1=`awk '{FS="/"}{print $2}' output`
var2=`awk '{FS="/"}{print $3}' output`
Mike
Reply With Quote
  #3 (permalink)  
Old 01-11-10, 16:25
kitaman kitaman is offline
Registered User
 
Join Date: Sep 2009
Location: Ontario
Posts: 526
Alternatively,
Code:
IFS="/"
read a b c d e f g <output
echo $c
echo $d
Reply With Quote
  #4 (permalink)  
Old 01-11-10, 18:54
vineelaregonda vineelaregonda is offline
Registered User
 
Join Date: May 2009
Posts: 43
Thank you for both of you.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On