Groups | Search | Server Info | Login | Register


Groups > alt.os.linux.mint > #47454

Re: Deleting old Kernels.

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups alt.os.linux.mint
Subject Re: Deleting old Kernels.
Date 2026-05-10 04:36 +0000
Organization A noiseless patient Spider
Message-ID <10tp20a$4vrm$1@dont-email.me> (permalink)
References <10tlnbe$388pq$1@dont-email.me> <10tlpft$12ob4$1@paganini.bofh.team> <10tm2vj$3b5db$1@dont-email.me> <10tmdbl$3dibl$1@dont-email.me> <10tn1mb$3ijna$2@dont-email.me>

Show all headers | View raw


On Sat, 9 May 2026 12:18:51 +0200, jjb wrote:

> #1.   Find all installed kernels
> @lines = `dpkg --list | grep -i 'linux-image'`;
> foreach (@lines) {
>     if (/^ii\s+linux-image-(\d[\S]+)/) {
>        push (@kernels, $1);
>     }
> }

OK, I didn’t notice you were specifically checking for packages with
status = installed. Here’s an update to my code that includes such a
check:

    import subprocess

    kernel_list = list \
      (
        n
        for s, n in
        (l.split("\t", 1)
            for l in
            subprocess.check_output
              (
                args = ("dpkg-query", "-f" "${Status;-1}\t${Package}\n", "-W", "*linux-image*"),
                text = True
              ).split("\n")
            if l != ""
        )
        if s == "i"
      )

    print(kernel_list)

The output list is much shorter. ;)

Back to alt.os.linux.mint | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-08 18:16 -0400
  Re: Deleting old Kernels. George <Invalid@invalid.invalid> - 2026-05-08 23:45 +0100
    Re: Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-08 21:34 -0400
      Re: Deleting old Kernels. Paul <nospam@needed.invalid> - 2026-05-09 00:31 -0400
        Re: Deleting old Kernels. jjb <jjb@invalid.invalid> - 2026-05-09 12:18 +0200
          Re: Deleting old Kernels. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-10 03:36 +0000
          Re: Deleting old Kernels. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-10 04:36 +0000
            Re: Deleting old Kernels. jjb <jjb@invalid.invalid> - 2026-05-10 12:11 +0200
    Re: Deleting old Kernels. RonB <ronb02NOSPAM@gmail.com> - 2026-05-09 11:06 +0000
      Re: Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-09 09:03 -0400
  Re: Deleting old Kernels. german newsgroups <usualsuspectrider@gmail.com> - 2026-05-09 08:18 +0200

csiph-web