CodeFaster

CodeFaster

Share this post

CodeFaster
CodeFaster
1-liner to get latest version in a changelog file

1-liner to get latest version in a changelog file

Tyler Adams's avatar
Tyler Adams
Jul 19, 2023
∙ Paid
3

Share this post

CodeFaster
CodeFaster
1-liner to get latest version in a changelog file
Share

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).

Thanks for reading CodeFaster! Subscribe for free to receive new posts and support my work.

Lets explain each step and observe transformation of partial output:

  1. 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
...
  1. 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)
...
  1. sed 1q: SED is a stream editor. It can perform lots of functions on files like, searching, find and replace, insertion/dele…

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Tyler Adams
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share