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
Extracting a Number from Passage laknar Shell Programming and Scripting 1 05-07-2008 07:15 PM
extracting a string start_shell Shell Programming and Scripting 2 09-30-2007 09:41 AM
Extracting a string from one file and searching the same string in other files mohancrr Shell Programming and Scripting 1 09-19-2007 04:17 AM
Extracting 10 digit number from txt files c19h28O2 Shell Programming and Scripting 9 08-07-2006 07:06 PM
extracting from a string preetikate Shell Programming and Scripting 1 03-11-2004 08:08 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-06-2008
ROOZ ROOZ is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 48
extracting a number from a string

Hi everyone,
I have a string as follow
ts1n65ulpa4096x16m16_130a_ss1p08v125c
i would like to extract 4096 and 16 from string and save it into two variable. but this string could also have the form
ts1n65ulpa32x16m16_130a_ss1p08v125c
therefore the number before "x" could be 2 or 3 digits. i use the following but this code is not able to extract more than one digit before "x"
echo "ts1n65ulpa4096x16_130a_ss1p08v125c" | sed -e 's/^[a-z0-9]*\([0-9][0-9]*x[0-9]*\).*/\1/'
the output is
6x16
which is missing 409 as the number before "x"
could anyone help me with this
 

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 09:29 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