The UNIX and Linux Forums  


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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assign Values to variables from a text file sarsani Shell Programming and Scripting 3 06-26-2009 08:05 PM
how to access values of awk/nawk variables outside the awk/nawk block? saniya Shell Programming and Scripting 5 05-13-2008 08:37 AM
read values from ps -ef into variables in ksh? JamesByars Shell Programming and Scripting 8 01-13-2008 08:12 AM
how do u assign the values to different variables when it is presneted in one line?? SwetaShah High Level Programming 2 10-24-2005 10:56 PM
Problem in assigning values to variables mohanprabu Shell Programming and Scripting 3 08-25-2005 05:44 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-01-2006
Rekha Rekha is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 2
Parsing and getting values of variables

suppose i have a file value where it returns 3 values

a=1 b=2 c=4

when i run it.

i am using this file in my shell script. how do i parse and get the value of a b and c?
  #2 (permalink)  
Old 08-01-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Try something like this:
Code:
$ a=`echo "a=1 b=2 c=4" | awk '{print $1}' | cut -d= -f2`
$ echo $a
1

  #3 (permalink)  
Old 08-01-2006
Rekha Rekha is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 2
Thanks so much
  #4 (permalink)  
Old 08-01-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
Another way :

Code:
echo "a=1 b=2 c=3" > filename
eval $(<filename)

Jean-Pierre.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0