Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > extracting part of a string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-07, 07:51
amolg amolg is offline
Registered User
 
Join Date: Oct 2007
Posts: 3
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
Reply With Quote
  #2 (permalink)  
Old 10-17-07, 02:48
parangiri parangiri is offline
Registered User
 
Join Date: Feb 2007
Location: Chennai, TN
Posts: 59
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
Reply With Quote
  #3 (permalink)  
Old 10-22-07, 04:32
amolg amolg is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 10-22-07, 06:02
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
Instead of cut
name1=${name#*@}
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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