![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| How to sort a string with numbers | ahjiefreak | Shell Programming and Scripting | 5 | 12-21-2007 10:52 AM |
| Extract numbers from a string and store in variables | davewg | Shell Programming and Scripting | 6 | 11-14-2007 05:22 AM |
| How do i get numbers from a string? | eliraza6 | Shell Programming and Scripting | 13 | 07-18-2007 07:04 AM |
| perl: string comparison as numbers | bishweshwar | UNIX for Advanced & Expert Users | 7 | 05-27-2007 12:54 AM |
| output only numbers from mixed string | nortypig | Shell Programming and Scripting | 10 | 08-29-2006 10:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
to find numbers in a string
I writing my script and got stuck in this function. Can someone help me?
I need to extract out the numbers inside a string. Ex: INPUT -> OUTPUT abcdef123 -> 123 abc123def -> 123 123abcdef -> 123 a123bc45d -> 123 45 abcdefghi -> -1 Thank you! |
|
||||
|
Quote:
Code:
sed "s/[^0-9]*\([0-9][0-9]*\)[^0-9]*/ \1 /g;s/^[^0-9][^0-9]*$/-1/" filename |
|
||||
|
Hi I have a similar problem, I would like to get a number that falls within a range from a string.
ex. input: "abcd 9034 efg 1234 hi" output: 9034 I would only want to get the number range from 9000-9999 I've tried to use sed/grep to get what I want for hours but not able to do it, can anyone advice on this? Thanks a lot!!! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|