Retrieve different set of numbers from String

March 1, 2012 at 03:41:58
Specs: Windows 7
Hi,

Could somebody please help me with getting numbers from a string. I found below sed command to get the numbers alone.

echo "asdf 12 asdf 34" | sed "s/[^0-9]//g;"

But, it doesn't give the numbers separately. It returns 1234. I want it as 12 34

Please help. Thanks in advance.


See More: Retrieve different set of numbers from String

Report •

#1
March 1, 2012 at 03:56:13
It's very easy.

Just give a space between the ^ symbol and 0-9.

That is, your command should be

echo "asdf 12 asdf 34" | sed "s/[^ 0-9]//g;"


Report •

#2
March 1, 2012 at 05:14:02
Thank you!

Report •
Related Solutions


Ask Question