0

Some commands display their output in a pager, and don't return. Here is an example of such a command :

apt changelog zsh

From the man apt page:

changelog
    changelog downloads a package changelog and displays it through sensible-pager. The server name and
    base directory is defined in the APT::Changelogs::Server variable (e. g.
    http://packages.debian.org/changelogs for Debian or http://changelogs.ubuntu.com/changelogs for
    Ubuntu). By default it displays the changelog for the version that is installed. However, you can
    specify the same options as for the install command.

...But nothing anywhere about passing options to said sensible-pager, or use another one.

How can I get, say, the N first lines of it, of better yet, parse the output to extract the information I need?

1 Answer 1

2

You can just pipe the changelog information to a different command like this:

$ apt changelog pkg_name | some_command

Or you can store the contents to a file like this:

$ apt changelog pkg_name > file.log

But it is going to show this warning:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
1
  • In fact I did that, but the command was taking so long to return that I though I didn't work :|
    – yPhil
    Commented Jan 5, 2021 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .