-2

In this time I am working of project, what tell you, what software you have installer and what you can install. In this time I have problem with this command: grep -hn Package: /var/lib/apt/lists/* . This command returns me package names, that's good, but I need hide the other text along it:

What i get:

    1:Package: alien-arena
    29:Package: alien-arena-server
    57:Package: alsa-firmware-loaders
    84:Package: amoeba
    115:Package: assaultcube
    141:Package: astromenace
    166:Package: astrometry-data-2mass
    189:Package: astrometry-data-2mass-00
    215:Package: astrometry-data-2mass-01
    241:Package: astrometry-data-2mass-02
    267:Package: astrometry-data-2mass-03
    293:Package: astrometry-data-2mass-04
    319:Package: astrometry-data-2mass-05
    345:Package: astrometry-data-2mass-06
    371:Package: astrometry-data-2mass-07
    397:Package: astrometry-data-2mass-08-19
    423:Package: atari800
    447:Package: b43-fwcutter
    469:Package: basilisk2
    509:Package: bgoffice-dict-downloader
    528:Package: biomaj-watcher
...

What I want to get:

alien-arena
alien-arena-server
alsa-firmware-loaders
amoeba
assaultcube
...

Thanks!

1 Answers1

1

grep -hn Package: /var/lib/apt/lists/* | cut -f 2 -d " " should do that.

What you are doing is:

pipe stdout of the grep command to cut command. -d " " parameter of cut commands instructs cut to use whitespace as delimiter and -f 2 to echo the second field.

Henrik Pingel
  • 8,676
  • 2
  • 24
  • 38