Your `sed` expression needs to be rethought because some `grep` versions have only two levels — _eg_ `2.16`. Take a look at this one: `/[^0-9]*\([0-9]*\.[\.0-9]*\).*/\1/`, it successfully parses version numbers regardless of the version level depth.

---

You cannot use `&&` to check the output of `sed` because it always returns `0`. You can either:
* Use the `-n` flag which will suppress output, and add the `p` command at the end to print group `\1` like so: `sed -n 's/[^0-9]*\([0-9]*\.[\.0-9]*\).*/\1/p'` which will print the version number.
* Use the `q` command to specify a custom exit code, and use `&&`, but it will only make it more complex.

---

Using `sort` and `head` at the end has no effect on the string `2.5.3`.