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
get characters from output of a command in a variable muaz Shell Programming and Scripting 3 06-02-2008 06:13 AM
Variable Manimpulation - special characters Nomaad Shell Programming and Scripting 1 04-04-2008 02:17 PM
Accessing invidual characters in a variable name suman_jakkula Shell Programming and Scripting 2 07-31-2006 09:23 AM
Replacing set of characters with a value of a variable prekida Shell Programming and Scripting 1 07-26-2005 05:14 PM
awk substr and variable for next n characters? smacleod UNIX for Dummies Questions & Answers 1 04-16-2002 11:05 AM

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

Join Date: Jan 2007
Posts: 13
Smile To get the characters from a variable

Hi ,
I need to get the specified word from the variable.can some one help me out in this ?
input=ASD34567P

i need to get the value as :

output1=34567


So i need to ignore the last character and get the remaining values.

THANKS IN ADVANCE.
Reply With Quote
Forum Sponsor
  #2  
Old 03-05-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by ithirak17 View Post
Hi ,
I need to get the specified word from the variable.can some one help me out in this ?
input=ASD34567P

i need to get the value as :
output1=34567

So i need to ignore the last character and get the remaining values.
Given the expected output and your requirement that the last character should be dropped, the outputs dont match.
34567 vs ASD34567
Reply With Quote
  #3  
Old 03-05-2008
Registered User
 

Join Date: Jan 2007
Posts: 13
Sorry i need to drop first three characters 34567.... and the last character also...
Reply With Quote
  #4  
Old 03-05-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by ithirak17 View Post
Sorry i need to drop first three characters 34567.... and the last character also...
Is it always the first 3 characters and the last or you want the alphabets alone to be dropped ?
Reply With Quote
  #5  
Old 03-05-2008
Registered User
 

Join Date: Jan 2007
Posts: 13
Post

yes Vino ....i need to drop the first three characters and the last character. it is afixed format so .. i need to get that number.
Reply With Quote
  #6  
Old 03-05-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by ithirak17 View Post
yes Vino ....i need to drop the first three characters and the last character. it is afixed format so .. i need to get that number.
You can start with this

Code:
output1=$(echo $input | sed -e "s/^...\(.*\).$/\1/g")
Reply With Quote
  #7  
Old 03-05-2008
Registered User
 

Join Date: Jan 2007
Posts: 13
Thanks vino....It working fine.I am not awware of sed can u please explain what this command will do?
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 11:44 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