I have the following line in a file:

      Linux Release............5.4.2.0-02 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:

      5.4.2.0-02 12_12_2011_07:31:23
link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

Try this:

sed -e 's/[^0-9]\+//'
link|improve this answer
what I need to change in the syntax in order to run it also on SOLARIS? – Eytan Jan 10 at 12:18
I don't think redirection works that way. Try echo " InSight Release............4.3.7.1-02.4 February-20,-2011-9:56:19" | sed 's/[^0-9]\+//', it works for me. – MadHatter Jan 10 at 13:44
1  
@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 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 at 16:56
Denis, yes, I did, and thanks for that - one learns something every day! – MadHatter Jan 10 at 17:02
feedback

One way using sed:

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

Result:

5.4.2.0-02 12_12_2011_07:31:23
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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