RegEX help needed | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

RegEX help needed

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-08-2013
skhichi skhichi is offline
Registered User
 
Join Date: Nov 2011
Last Activity: 8 July 2013, 3:09 AM EDT
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
RegEX help needed

Hi,

Have to filter out string before the last underscore in the following

input: UNIX_Solaris_59_KSH

output: UNIX_Solaris_59

dummy one but

Thanks & Regards,
Sourabh Singh Khichi

Last edited by vbe; 01-08-2013 at 09:00 AM.. Reason: icodes...
Sponsored Links
    #2  
Old 01-08-2013
bartus11's Avatar
bartus11 bartus11 is offline Forum Staff  
Moderator
 
Join Date: Apr 2009
Last Activity: 23 July 2014, 5:15 PM EDT
Posts: 3,707
Thanks: 7
Thanked 1,141 Times in 1,112 Posts
Is the input stored in a file or in a shell variable?
Sponsored Links
    #3  
Old 01-08-2013
skhichi skhichi is offline
Registered User
 
Join Date: Nov 2011
Last Activity: 8 July 2013, 3:09 AM EDT
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
ok with anything file or variable ..... any can help
    #4  
Old 01-08-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 July 2014, 10:05 PM EDT
Location: San Jose, CA, USA
Posts: 4,124
Thanks: 160
Thanked 1,410 Times in 1,195 Posts
Assuming you're using ksh, here are two ways to do it:

Code:
in=UNIX_Solaris_59_KSH
echo ${in%_*}
echo $in | sed 's/_[^_]*$//'

Sponsored Links
    #5  
Old 01-08-2013
skhichi skhichi is offline
Registered User
 
Join Date: Nov 2011
Last Activity: 8 July 2013, 3:09 AM EDT
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
thanks a lot for your help
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regex Needed:( jlaigo2 UNIX for Dummies Questions & Answers 6 10-31-2012 12:02 PM
Help needed in regex lorzinian Shell Programming and Scripting 2 10-09-2012 09:21 AM
perl regex help needed zing_foru Shell Programming and Scripting 8 09-16-2012 11:34 AM
Regex help needed Bloomy Shell Programming and Scripting 1 03-19-2012 10:54 AM
Sed and regex help needed marknu1 Shell Programming and Scripting 9 08-08-2008 02:13 PM



All times are GMT -4. The time now is 12:13 AM.