![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to sort a string with numbers | ahjiefreak | Shell Programming and Scripting | 5 | 12-21-2007 06:52 AM |
| Extract numbers from a string and store in variables | davewg | Shell Programming and Scripting | 6 | 11-14-2007 01:22 AM |
| How do i get numbers from a string? | eliraza6 | Shell Programming and Scripting | 13 | 07-18-2007 04:04 AM |
| perl: string comparison as numbers | bishweshwar | UNIX for Advanced & Expert Users | 7 | 05-26-2007 09:54 PM |
| output only numbers from mixed string | nortypig | Shell Programming and Scripting | 10 | 08-29-2006 07:30 PM |
|
|
LinkBack | Thread Tools | 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! |
| Forum Sponsor | ||
|
|
|
|||
|
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!!! |
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|