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 lines between 2 strings only if the pattern patches simran Shell Programming and Scripting 5 04-23-2008 04:58 PM
extracting a set of strings from a text file Deanne Shell Programming and Scripting 2 09-20-2007 11:31 PM
Extracting the lines between 2 strings of a file babloo Shell Programming and Scripting 2 02-14-2007 11:27 AM
Help with extracting strings from a file cmsdelhi Shell Programming and Scripting 7 01-12-2007 09:49 AM
Extracting strings hugow UNIX for Dummies Questions & Answers 1 06-24-2005 06:09 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 05-26-2008
gobi gobi is offline
Registered User
  
 

Join Date: May 2008
Posts: 13
extracting numbers from strings

Hello all,

I am being dumb with this and I know there is a simple solution.

I have a file with the follwing lines

Code:
 bc stuff (more)...............123
 bc stuffagain (moretoo)............0
 bc stuffyetagain (morehere)......34
 failed L3 thing..............1
 failed this status.............24
 failed that status.............253
 failed some kind of check........0
I want to pull the numbers off the end of the lines. I can use cut but that is not very robust. I have been using sed but cannot get it to work properly.

I don't think this is very hard. It's been a long day.

Thanks!

gobi

Last edited by Yogesh Sawant; 05-27-2008 at 02:01 AM.. Reason: added code tags
  #2 (permalink)  
Old 05-26-2008
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
If you just want to extract the last field:
Code:
$ sed -n 's/.*\.//;p' gobi.txt
or
$ awk 'BEGIN{FS="."} {print $NF}' gobi.txt
And to extract the digits:

Code:
$ sed 's/.*\.\.\([0-9]*\).*/\1/' gobi.txt
//Jadu
  #3 (permalink)  
Old 05-26-2008
gobi gobi is offline
Registered User
  
 

Join Date: May 2008
Posts: 13
yes thank you.

I left out the \.\. from the sed command. like I said its been a long day.

Thanks!
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 05:32 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