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 > 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
extracting only numerals from string. tushar_tus Shell Programming and Scripting 4 04-30-2009 01:06 AM
How to build a command into a string rather than execute the command littlejon Shell Programming and Scripting 1 05-29-2008 08:05 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 06:06 PM
Command String Help NetJones UNIX for Dummies Questions & Answers 2 03-15-2008 07:20 PM
What is this command string doing? coco UNIX for Dummies Questions & Answers 1 05-02-2005 05:06 PM

Closed Thread
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 Rate Thread Display Modes
  #1 (permalink)  
Old 05-13-2009
happyrain happyrain is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 15
Using CUT command to get only numerals from a string

I need help to get only the numerals from a string

Ex :

var1=Nightfox has 2 red apple(s)

I need to cut only the numeral 2 and move it to a variable.

var2=`$var1 | cut -c 14`

the cut by character doesnt work, how to get only the numeral ?
  #2 (permalink)  
Old 05-13-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,524
Code:
echo $var1 |grep -Eo "[0-9]+"
  #3 (permalink)  
Old 05-13-2009
happyrain happyrain is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 15
It worked, thnx
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 04:25 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