The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Separate string arghya_owen Shell Programming and Scripting 3 05-14-2008 12:35 AM
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 09:33 AM
insert pipe in file to separate values DebianJ UNIX for Advanced & Expert Users 5 03-20-2006 04:20 PM
separate out the column ust Shell Programming and Scripting 6 12-29-2005 04:11 AM
How to separate a variable whatisthis Shell Programming and Scripting 4 11-02-2004 10:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-06-2008
Registered User
 

Join Date: Aug 2008
Posts: 26
to separate values from a string

Hi
I would like to take input from user like username/password@connectstring

I should be able to cut the username and password and connect string
for example if someone enters like
sam/sammy@ora1

my program should take sam as username sammy as password and ora1 as connectstring and assign to different variables

Thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 10-06-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 549
will this do??
Code:
 
read input?"enter value"
echo "$input"|awk -F\/ '{print $1$2}'
Reply With Quote
  #3  
Old 10-06-2008
cfajohnson's Avatar
Registered User
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 791
Quote:
Originally Posted by ssuresh1999 View Post
if someone enters like

sam/sammy@ora1

my program should take sam as username sammy as password and ora1 as connectstring and assign to different variables

There is no need for any external command:
Code:
input=sam/sammy@ora1
up=${input%@*}
username=${up%/*}
password=${up#*/}
connectstring=${input#*@}
Reply With Quote
  #4  
Old 10-07-2008
Registered User
 

Join Date: Aug 2008
Posts: 26
Thanks so much for your answers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0