Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    43

    Unanswered: 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

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Something like this should be ok
    Code:
    var1=`awk '{FS="/"}{print $2}' output`
    var2=`awk '{FS="/"}{print $3}' output`
    Mike

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Alternatively,
    Code:
    IFS="/"
    read a b c d e f g <output
    echo $c
    echo $d

  4. #4
    Join Date
    May 2009
    Posts
    43
    Thank you for both of you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •