Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    3

    Unanswered: extracting part of a string

    Hi,

    I have one file in which i have one variable where i am storing email ids.
    I have several users with different email ids.
    I want to extract the following,
    for e.g the email id is testing@abc.def.com
    my purpose is to search users with abc.def.com or extract the abc.def.com part from the email id.

    Please help me how can i write the shell script to perform this operation.

    Thanks,
    Amol

  2. #2
    Join Date
    Feb 2007
    Location
    Chennai, TN
    Posts
    68
    Hi,
    Are you storing only the email ids in the file?. May i know the contents in the file?. That might help me to answer your question

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Got the solution, here it is,

    name="amollg@abc.def.com"
    name1=`echo $name|cut -d '@' -f 2-`
    echo $name1

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Instead of cut
    name1=${name#*@}

Posting Permissions

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