I'm trying to get the version number out of a string which looks like this:
[7:38:06 PM] [semantic-release] › ℹ Running semantic-release version 17.1.2
[7:38:09 PM] [semantic-release] › ✔ Published release 1.0.7 on default channel
As I need to do this in BusyBox, I can't use grep with the -P option:
grep -oP 'Published release \K.*? '
So I tried to use sed, but my attempt doesn't return anything:
sed -n 's/.*Published release (.*) .*/\1/p'
What is wrong with this command or is there a 'native' solution to get 1.0.7?
You can use
sedlike this:See an online demo:
Details
-n- suppresses the default line output.*Published release \([^ ]*\).*- matches.*- any 0 or more charsPublished release- a literal text\([^ ]*\)- Group 1: any zero or more chars other than a space.*- any 0 or more chars\1- replaces with Group 1 valuep- prints the result of the substitution