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*

3
  • For sed, ^.* is greedy and consumes all but the last digit, and + needs to be \+ or else use the posix \([0-9][0-9]*\).... and in any case 's/[^0-9]*//g' works just as well, ... Thanks for the tr -c` example, but isn't that trailing \012 surperfluous? Commented Mar 8, 2012 at 0:48
  • @Peter Thanks for catching that. I'd have sworn I tested the sed example. :( I've changed it to your version. Regarding \012: it is needed otherwise tr will eat the newlines. Commented Mar 8, 2012 at 0:58
  • Aha... I was seeing it as \0, 1, 2 (or even \, 0, 1, 2). I'm not well enough attuned to octal it seems.. Thanks. Commented Mar 8, 2012 at 6:48