I got a bash script and I started to write a changelog to keep track of changes.
I added in the script a function that echoes "Script version --> "
But I have to manually edit it.
So I would need a function to get the first word until space of the last line and store it as $CURRENTVERSION
Changelog syntax is:
v-0.3.2 Added x, y.
v-0.3.2.1 Fixed y.
v-0.4 Added z.
Briefly I would need to store v-0.4
as $CURRENTVERSION
Using awk:
awk '{w=$1} END{print w}' file
OR using sed:
sed -n '$s/^\([^ ]*\).*$/\1/p' file