The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
regarding replace a part of a string madhu_aqua14 UNIX for Dummies Questions & Answers 7 08-04-2008 10:07 AM
Need help regarding replacing a part of string veerapureddy Shell Programming and Scripting 1 03-17-2008 09:02 AM
How do i grep a pattern from part of LINE 123nagendrabhi SUN Solaris 3 01-05-2008 03:16 AM
Finding part of a string DAFNIX Shell Programming and Scripting 4 09-20-2006 11:24 PM
vi part-pattern matching and deletion vino UNIX for Dummies Questions & Answers 5 04-04-2005 01:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-08-2007
bluemoon1 bluemoon1 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 53
how to get the last part of a string followed by a pattern

assuming "cat" is the pattern, string (regardless length)
asdadfcat4

I need to get 4

for eirtrjkkkcat678- I'd get 678

(in b-shell)
Thanks in advance!!!
  #2 (permalink)  
Old 09-08-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Code:
echo "1test23string456" | sed "s/^.*[^0-9]\([0-9][0-9]*\)$/\1/"
  #3 (permalink)  
Old 09-08-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
Code:
# var=eirtrjkkkcat678
# echo ${var##*cat}
678
  #4 (permalink)  
Old 09-08-2007
bluemoon1 bluemoon1 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 53
robotronic:

I can't get the digits followed "string", instead, I get "Variable syntax".
Why? Would you explain each syntax in sed- I'm a newbie & confused. It looks to me it tries to get at least two digits out of from the end of the string...
Thanks for your help!

ghostdog:
I assume that wasn't b-shell script? I got "bad substitution" running it.
Thanks
  #5 (permalink)  
Old 09-08-2007
bluemoon1 bluemoon1 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 53
Hi gentle peopel:

I think I got it all right:

echo "beginingPattern3568" | sed 's/^.*Pattern\([0-9]*\)$/\1/'

Thanks for helping, again.

bluemoon
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0