Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • yes, sure only the numbers, but only your 3rd example works correctly Commented Jan 18, 2014 at 0:08
  • @rubo77 Works for me. The first two examples do exactly what you ask in your title. Or did you want to strip off the unit as well? In that case, add | sed 's/ .*//' at the end of the first two examples. Of course there are many other ways to do it. Commented Jan 18, 2014 at 0:13
  • a bit shorter with + instead of *: cat test | sed 's/[^.0-9]\+/:/g' | cut -d : -f 6 Commented Sep 1, 2016 at 8:29
  • @rubo77 If your sed supports it, that is. It's supported by GNU and BusyBox but not by e.g. BSD or Solaris. POSIX specifies + and ? in ERE but leaves \+ and \? in BRE undefined. Commented Sep 1, 2016 at 8:57
  • So the right option for columned input into cut would be -c35-38 Commented Jun 20, 2020 at 2:33