Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    2

    Unanswered: Help needed with using sed

    Hi,

    From the word Hello234.p456world345.678.exe I need to extract "234.p456" and assign it to another variable.
    Can anyone help me with this using sed?

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    sed is a program that reads a file and performs actions on each line of the file depending upon the instructions that it is given.
    You need to use "cut".
    Code:
    word=`echo "Hello234.p456world345.678.exe" |cut -c6-13`
    Alternatively, if the sub-string is not column based,
    Code:
    word=`echo "Hello234.p456world345.678.exe" |cut -d"o" -f2`
    word=`echo $word |cut -d"w" -f1`

  3. #3
    Join Date
    Jan 2004
    Location
    Issy les Moulineaux, France
    Posts
    24
    Hi,
    if you need to get everything between hello and world, you can use :
    Code:
    echo Hello234.p456world345.678.exe | sed -ne "s/^Hello\(.*\)world.*/\1/p"
    Regards,
    Eric

Posting Permissions

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