Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following line in a file:

      Linux Release............ 12_12_2011_07:31:23

How do I remove all characters before the first number with sed or awk?

I wish to get the following result: 12_12_2011_07:31:23
share|improve this question
up vote 2 down vote accepted

Try this:

sed -e 's/[^0-9]\+//'
share|improve this answer
what I need to change in the syntax in order to run it also on SOLARIS? – Eytan Jan 10 '12 at 12:18
I don't think redirection works that way. Try echo " InSight Release............ February-20,-2011-9:56:19" | sed 's/[^0-9]\+//', it works for me. – MadHatter Jan 10 '12 at 13:44
@Eytan: You want it to work on Solaris, but you tagged your question "Linux". Do you need it to work on both? – Dennis Williamson Jan 10 '12 at 16:54
@MadHatter: Did you mean for your comment to be attached to Birei's answer? If so, the <<< is for a Bash here-string. Other shells may not support it. – Dennis Williamson Jan 10 '12 at 16:56
Denis, yes, I did, and thanks for that - one learns something every day! – MadHatter Jan 10 '12 at 17:02

One way using sed:

sed 's/^[^0-9]*//' <<<"      Linux Release............ 12_12_2011_07:31:23"

Result: 12_12_2011_07:31:23
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.