1-liner to get latest version in a changelog file
Heres the one-liner in a code block:
cat debian/changelog | awk '{print $2;}' | sed 1q | tr -d '()' | cut -d - -f 1
This code is used to extract a piece of information (the version number of a Debian package) from a well-structured text (the Debian changelog file).
Lets explain each step and observe transformation of partial output:
cat debian/changelog: This command is used to view the content of the debian/changelog file.
json-toolkit (1.2.0-4) focal; urgency=medium
...
awk '{print $2;}': AWK is a programming language that is designed for text processing. This portion of the one-liner attempts to print out the second field (the fields are divided by whitespaces by default) of every line of debian/changelog. Characters inside the parentheses are considered one field.
(1.2.0-4)
...
sed 1q: SED is a stream editor. It can perform lots of functions on files like, searching, find and replace, insertion/dele…