On 2020-07-27 at 10:25, Rodolfo Medina wrote: > The Wanderer <wanderer@fastmail.fm> writes: > >> On 2020-07-27 at 09:56, Rodolfo Medina wrote: >>> Now, I want to remove all >>> tha packages I installed on last july 23th. To do so, I do: >>> >>> $ grep "2015-12-19.*.install " /var/log/dpkg.log | awk '{ print $4 }' | cut -d: -f1 | tr '\n' ' ' >>> >>> How can I modify the above command so to include - when it is present - also >>> that important suffix? >> >> Drop the '| cut -d: -f1' part. That explicitly gets rid of the suffix. >> As far as I can tell from trivial testing, the resulting package list is >> in the correct syntax to be passed to apt-get or aptitude for removal. > > Unfortunately, > > root@lenovo:~# aptitude purge "2020-07-23.*.install " /var/log/dpkg.log | awk '{ print $4 }' | tr '\n' ' ' > Unable to apply some actions, aborting > information... information... package root@lenovo:~# You have your syntax wrong. This attempts to run the following commands, in order, passing the output of each one as input to the next one: aptitude purge "2020-07-23.*.install " /var/log/dpkg.log awk '{ print $4 }' tr '\n' ' ' > Strange, because: > > $ grep "2020-07-23.*.install " /var/log/dpkg.log | awk '{ print $4 }' | tr '\n' ' ' > xml-core:all docutils-common:all docutils-doc:all libimagequant0:amd64 libjs-sphinxdoc:all python-alabaster:all python-asn1crypto:all python-babel-localedata:all python-tz:all python-babel:all python-certifi:all python-cffi-backend:amd64 python-enum34:all python-ipaddress:all python-cryptography:amd64 python-roman:all python-docutils:all python-idna:all python-imagesize:all python-markupsafe:amd64 python-jinja2:all python-olefile:all python-openssl:all python-pyparsing:all python-packaging:all python-pil:amd64 python-pygments:all python-urllib3:all python-requests:all python-typing:all sphinx-common:all python-sphinx:all nasm:amd64 yasm:amd64 cmake-data:all libcurl4:amd64 librhash0:amd64 libuv1:amd64 cmake:amd64 libchromaprint-tools:amd64 libchromaprint-dev:amd64 frei0r-plugins-dev:amd64 libunistring-dev:amd64 libunbound8:amd64 libgnutls-dane0:amd64 libopts25:amd64 gnutls-bin:amd64 libgmpxx4ldbl:amd64 libgmp-dev:amd64 libgnutlsxx28:amd64 libidn2-dev:amd64 libp11-kit-dev:amd64 libtas n1-6-dev:amd64 nettle-dev:amd64 libgnutls28-dev:amd64 libtasn1-doc:all libdpkg-perl:all libfile-fcntllock-perl:amd64 pkg-config:amd64 ladspa-sdk:amd64 aom-tools:amd64 libaom-dev:amd64 libserd-0-0:i386 libsord-0-0:i386 libsratom-0-0:i386 liblilv-0-0:i386 libserd-dev:amd64 libsord-dev:amd64 lv2-dev:amd64 libsratom-dev:amd64 liblilv-dev:amd64 libraw1394-dev:amd64 libiec61883-dev:amd64 libraw1394-tools:amd64 libraw1394-11:i386 libiec61883-0:i386 libraw1394-dev:i386 > > Maybe all those `:all'...? Then get cut off only them? What you want to do instead is to run this exact latter command, and pass the output of that into the 'aptitude purge' command. To do that, you use a subshell. This can be done in either of two ways: with backticks (that is, `, from the key to the left of the '1' key), or with $() syntax. The former is easier to type, but the latter is more versatile, because it can be nested. Try: $ aptitude purge $(grep "2020-07-23.*.install " /var/log/dpkg.log | awk '{ print $4 }' | tr '\n' ' ') and see what you get. As I understand matters, running 'command' in a subshell results in the stdout of that command being dropped into the place in the original command line where the subshell was located. For example, the command $ aptitude purge $(echo packagename) results in running the actual command $ aptitude purge packagename Note that if the output of the subshell command includes spaces, or other special characters, you need to handle shell quoting and the result can get very messy. I don't have a good handle on the more advanced examples of it myself, but there are reference guides out there for the basic principles, although I don't keep track of them. -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
Attachment:
signature.asc
Description: OpenPGP digital signature