Issue
My task is to grab latest version of maven in bash script using curl https://apache.osuosl.org/maven/maven-3/ Output should be: 3.8.5
curl -s "https://apache.osuosl.org/maven/maven-3/" | grep -o "[0-9].[0-9].[0-9]" | tail -1
works for me ty
Solution
One way is to
- Use grep to only get the lines containing the
folder
link - Use sed with an regex to get only the version number
- Use
sort
to sort the lines - Use
tail -n1
to get the last line
curl -s https://apache.osuosl.org/maven/maven-3/ \
| grep folder \
| gsed -E 's/.*([[:digit:]]\.[[:digit:]]\.[[:digit:]]).*/\1/' \
| sort \
| tail -n1
Output:
3.8.5
Answered By - 0stone0
Answer Checked By - Robin (JavaFixing Admin)