dpkg-Pakete rausfiltern aus /var/log/apt/history.log (awk?)

Vom einfachen Programm zum fertigen Debian-Paket, Fragen rund um Programmiersprachen, Scripting und Lizenzierung.
Antworten
Benutzeravatar
pangu
Beiträge: 1400
Registriert: 15.11.2011 20:50:52
Lizenz eigener Beiträge: GNU General Public License
Wohnort: /proc/1

dpkg-Pakete rausfiltern aus /var/log/apt/history.log (awk?)

Beitrag von pangu » 17.03.2014 21:21:43

Hi Leute,

ich hab mir heute "phoronix-test-suite" installiert gehabt und wollte was benchen. Dabei habe ich den Befehl

Code: Alles auswählen

phoronix-test-suite benchmark universe
gebraucht. Dazu mussten ein Haufen Pakete heruntergeladen und installiert werden, die für den Test notwendig waren. Da ich mittlerweile phoronix-test-suite mit "apt-get purge phoronix-test-suite && apt-get autoremove" wieder entfernt habe, brauche ich diese ganzen Pakete nicht. Leider hat "autoremove" nicht alle wieder entfernt, warum nicht?

Ich hab mir /var/log/apt/history.log angeschaut und die ganzen zig Pakete gefunden. Bloss wie krieg ich die jetzt alle so gefiltert, dass ich sie an "apt-get purge ..." übergeben könnte? Ich glaub da ist nun Cae mit seinen awk-Künsten gefragt :-)

Würde mich freuen, wenn mir jemand hier behilflich sein könnte. Hier der Auszug der entsprechend vielen Pakete aus der /var/log/apt/history.log:

Code: Alles auswählen

Start-Date: 2014-03-17  20:57:25
Install: libglapi-mesa:armhf (8.0.5-4+deb7u2, automatic), libpopt-dev:armhf (1.16-7), libgtk2.0-common:armhf (2.24.10-2, automatic), libsdl1.2debian:armhf (1.2.15-5,
 automatic), libsm-dev:armhf (1.2.1-2, automatic), libatk1.0-0:armhf (2.4.0-2, automatic), libboost-chrono1.49.0:armhf (1.49.0-3.2, automatic), libts-0.0-0:armhf (1.
0-11, automatic), libboost-system1.49.0:armhf (1.49.0-3.2, automatic), libboost-locale1.49-dev:armhf (1.49.0-3.2, automatic), libxfixes3:armhf (5.0-4+deb7u1, automat
ic), shared-mime-info:armhf (1.0-1+b1, automatic), libqt4-opengl:armhf (4.8.2+dfsg-11, automatic), libperl-dev:armhf (5.14.2-21+deb7u1), libtorque2:armhf (2.4.16+dfs
g-1+deb7u2, automatic), libboost-python1.49.0:armhf (1.49.0-3.2, automatic), libgmp10:armhf (5.0.5+dfsg-2, automatic), libice-dev:armhf (1.0.8-2, automatic), libmpfr
4:armhf (3.1.0-5, automatic), libqt4-declarative:armhf (4.8.2+dfsg-11, automatic), libfftw3-bin:armhf (3.3.2-3.1, automatic), x11proto-xext-dev:armhf (7.2.1-1, autom
atic), liblcms1:armhf (1.19.dfsg-1.2, automatic), libnettle4:armhf (2.4-3, automatic), libboost-thread-dev:armhf (1.49.0.1, automatic), libfftw3-dev:armhf (3.3.2-3.1
), libatk1.0-dev:armhf (2.4.0-2, automatic), libportaudio0:armhf (18.1-7.1, automatic), libnss3:armhf (3.14.5-1, automatic), pkg-config:armhf (0.26-1+b1, automatic),
 libglib2.0-bin:armhf (2.33.12+really2.32.4-5, automatic), liblapack-dev:armhf (3.4.1+dfsg-1+deb70u1), libboost-graph-dev:armhf (1.49.0.1, automatic), libqtdbus4:arm
hf (4.8.2+dfsg-11, automatic), libboost-chrono-dev:armhf (1.49.0.1, automatic), x11proto-kb-dev:armhf (1.0.6-2, automatic), libglib2.0-dev:armhf (2.33.12+really2.32.
4-5, automatic), libicu48:armhf (4.8.1.1-12+deb7u1, automatic), libvorbisfile3:armhf (1.3.2-1.3, automatic), libblas-dev:armhf (1.2.20110419-5), libxcb-shm0-dev:armh
f (1.8.1-2+deb7u1, automatic), qdbus:armhf (4.8.2+dfsg-11, automatic), libboost-test1.49.0:armhf (1.49.0-3.2, automatic), libboost-regex1.49.0:armhf (1.49.0-3.2, automatic), libboost-date-time-dev:armhf (1.49.0.1, automatic), libpixman-1-0:armhf (0.26.0-4+deb7u1, automatic), libboost-filesystem1.49-dev:armhf (1.49.0-3.2, automatic), gir1.2-gdkpixbuf-2.0:armhf (2.26.1-1, automatic), libsdl-gfx1.2-4:armhf (2.0.23-3, automatic), libqt4-dev-bin:armhf (4.8.2+dfsg-11, automatic), x11proto-xinerama-dev:armhf (1.2.1-2, automatic), libboost-program-options1.49-dev:armhf (1.49.0-3.2, automatic), libboost-all-dev:armhf (1.49.0.1), libpango1.0-dev:armhf (1.30.0-1, automatic), libboost-timer1.49-dev:armhf (1.49.0-3.2, automatic), libboost-wave1.49.0:armhf (1.49.0-3.2, automatic), libavahi-common-data:armhf (0.6.31-2, automatic), libpcre3-dev:armhf (8.30-5, automatic), g++-4.6:armhf (4.6.3-14, automatic), libqt4-test:armhf (4.8.2+dfsg-11, automatic), libtie-simple-perl:armhf (1.03-1, automatic), cmake-data:armhf (2.8.9-1, automatic), libboost-mpi-python-dev:armhf (1.49.0.1, automatic), libqt4-dbus:armhf (4.8.2+dfsg-11, automatic), x11proto-render-dev:armhf (0.11.1-2, automatic), libxxf86vm1:armhf (1.1.2-1+deb7u1, automatic), libboost-iostreams-dev:armhf (1.49.0.1, automatic), libboost-locale1.49.0:armhf (1.49.0-3.2, automatic), libopenmpi1.3:armhf (1.4.5-1, automatic), libxmlrpc-core-c3:armhf (1.16.33-3.2, automatic), libboost-dev:armhf (1.49.0.1, automatic), libboost-system-dev:armhf (1.49.0.1, automatic), libboost-graph-parallel1.49-dev:armhf (1.49.0-3.2, automatic), libatk-wrapper-java:armhf (0.30.4-3, automatic), libglu1-mesa:armhf (8.0.5-4+deb7u2, automatic), libxcb-glx0:armhf (1.8.1-2+deb7u1, automatic), libc-dev-bin:armhf (2.13-38+deb7u1, automatic), libqt4-qt3support:armhf (4.8.2+dfsg-11, automatic), libxi-dev:armhf (1.6.1-1+deb7u1, automatic), libclass-inspector-perl:armhf (1.27-1, automatic), m4:armhf (1.4.16-3, automatic), java-common:armhf (0.47, automatic), libxrender-dev:armhf (0.9.7-1+deb7u1, automatic), autoconf:armhf (2.69-1), libgomp1:armhf (4.7.2-5, automatic), libqt4-opengl-dev:armhf (4.8.2+dfsg-11), libboost-regex1.49-dev:armhf (1.49.0-3.2, automatic), libboost-math1.49-dev:armhf (1.49.0-3.2, automatic), libboost-program-options1.49.0:armhf (1.49.0-3.2, automatic), libfftw3-3:armhf (3.3.2-3.1, automatic), libcairo2-dev:armhf (1.12.2-3, automatic), mesa-common-dev:armhf (8.0.5-4+deb7u2, automatic), libboost-filesystem-dev:armhf (1.49.0.1, automatic), python-dev:armhf (2.7.3-4+deb7u1, automatic), libboost-timer1.49.0:armhf (1.49.0-3.2, automatic), libcairo2:armhf (1.12.2-3, automatic), libx11-xcb1:armhf (1.5.0-1+deb7u1, automatic), libibverbs-dev:armhf (1.1.6-1, automatic), libxdmcp-dev:armhf (1.1.1-1, automatic), libwebp2:armhf (0.1.3-3+nmu1, automatic), libvorbisenc2:armhf (1.3.2-1.3, automatic), libjbig0:armhf (2.0-2), gir1.2-atk-1.0:armhf (2.4.0-2, automatic), g++:armhf (4.6.3-8, automatic), libgdk-pixbuf2.0-common:armhf (2.26.1-1, automatic), linux-libc-dev:armhf (3.2.54-2, automatic), libaio-dev:armhf (0.3.109-3), libboost-mpi-python1.49.0:armhf (1.49.0-3.2, automatic), libboost-mpi1.49-dev:armhf (1.49.0-3.2, automatic), libxcb-render0:armhf (1.8.1-2+deb7u1, automatic), libpng12-dev:armhf (1.2.49-1), libsdl-net1.2:armhf (1.2.8-2, automatic), gcc-4.6:armhf (4.6.3-14, automatic), libboost1.49-dev:armhf (1.49.0-3.2, automatic), libdpkg-perl:armhf (1.16.12, automatic), libboost-serialization1.49-dev:armhf (1.49.0-3.2, automatic), libboost-graph1.49-dev:armhf (1.49.0-3.2, automatic), libfontconfig1-dev:armhf (2.9.0-7.1, automatic), fonts-sil-gentium-basic:armhf (1.1-5, automatic), libpcrecpp0:armhf (8.30-5, automatic), libcapture-tiny-perl:armhf (0.18-1, automatic), libdatrie1:armhf (0.2.5-3, automatic), x11proto-composite-dev:armhf (0.4.2-2, automatic), xtrans-dev:armhf (1.2.7-1, automatic), fontconfig:armhf (2.9.0-7.1, automatic), libparams-util-perl:armhf (1.07-1, automatic), libboost-test-dev:armhf (1.49.0.1, automatic), libboost-wave-dev:armhf (1.49.0.1, automatic), libboost-thread1.49.0:armhf (1.49.0-3.2, automatic), libqt4-xmlpatterns:armhf (4.8.2+dfsg-11, automatic), libqt4-dev:armhf (4.8.2+dfsg-11), libboost-serialization-dev:armhf (1.49.0.1, automatic), libboost-date-time1.49-dev:armhf (1.49.0-3.2, automatic), libjson0:armhf (0.10-1.2, automatic), libelf1:armhf (0.152-1+wheezy1, automatic), libdirectfb-1.2-9:armhf (1.2.10.0-5, automatic), libboost-timer-dev:armhf (1.49.0.1, automatic), emacsen-common:armhf (2.0.5, automatic), gir1.2-freedesktop:armhf (1.32.1-1, automatic), x11proto-core-dev:armhf (7.0.23-1, automatic), libxcursor-dev:armhf (1.1.13-1+deb7u1, automatic), libqt4-help:armhf (4.8.2+dfsg-11, automatic), libboost-serialization1.49.0:armhf (1.49.0-3.2, automatic), libboost-date-time1.49.0:armhf (1.49.0-3.2, automatic), libboost-signals-dev:armhf (1.49.0.1, automatic), cmake:armhf (2.8.9-1), libdrm2:armhf (2.4.40-1~deb7u2, automatic), libboost-wave1.49-dev:armhf (1.49.0-3.2, automatic), libboost-signals1.49-dev:armhf (1.49.0-3.2, automatic), cpp:armhf (4.6.3-8, automatic), libpango1.0-0:armhf (1.30.0-1, automatic), gfortran-4.6:armhf (4.6.3-14, automatic), libcups2:armhf (1.5.3-5+deb7u1, automatic), gcc:armhf (4.6.3-8, automatic), libglu1-mesa-dev:armhf (8.0.5-4+deb7u2, automatic), libcairo-script-interpreter2:armhf (1.12.2-3, automatic), libqtcore4:armhf (4.8.2+dfsg-11, automatic), ttf-sil-gentium-basic:armhf (1.1-5, automatic), libsdl-ttf2.0-0:armhf (2.0.11-2, automatic), libmikmod2:armhf (3.1.12-5, automatic), libgif4:armhf (4.1.6-10, automatic), x11proto-randr-dev:armhf (1.3.2-2, automatic), x11proto-damage-dev:armhf (1.2.1-2, automatic), xorg-sgml-doctools:armhf (1.10-1, automatic), libfile-which-perl:armhf (1.09-1, automatic), libxft2:armhf (2.3.1-1, automatic), openjdk-6-jre-headless:armhf (6b27-1.12.6-1~deb7u1, automatic), gir1.2-glib-2.0:armhf (1.32.1-1, automatic), freeglut3-dev:armhf (2.6.0-4), libssl-dev:armhf (1.0.1e-2+deb7u4, automatic), qt4-qmake:armhf (4.8.2+dfsg-11, automatic), libxt-dev:armhf (1.1.3-1+deb7u1, automatic), libgtk2.0-dev:armhf (2.24.10-2), libxcomposite1:armhf (0.4.3-2+b1, automatic), mpi-default-dev:armhf (1.0.1, automatic), tzdata-java:armhf (2013i-0wheezy1, automatic), libxext-dev:armhf (1.3.1-2+deb7u1, automatic), libboost-mpi-python1.49-dev:armhf (1.49.0-3.2, automatic), libjpeg62-dev:armhf (6b1-3), gfortran:armhf (4.6.3-8), libice6:armhf (1.0.8-2, automatic), openjdk-6-jre:armhf (6b27-1.12.6-1~deb7u1), libboost-test1.49-dev:armhf (1.49.0-3.2, automatic), libthai0:armhf (0.1.18-2, automatic), gir1.2-pango-1.0:armhf (1.30.0-1, automatic), openjdk-6-jre-lib:armhf (6b27-1.12.6-1~deb7u1, automatic), libxdamage-dev:armhf (1.1.3-2+b1, automatic), libboost-math-dev:armhf (1.49.0.1, automatic), libboost-signals1.49.0:armhf (1.49.0-3.2, automatic), libgirepository-1.0-1:armhf (1.32.1-1, automatic), libsdl-pango1:armhf (0.1.2-6, automatic), libboost-python1.49-dev:armhf (1.49.0-3.2, automatic), zlib1g-dev:armhf (1.2.7.dfsg-13), gcc-4.6-base:armhf (4.6.3-14, automatic), x11proto-input-dev:armhf (2.2-1, automatic), libqt4-sql:armhf (4.8.2+dfsg-11, automatic), libglib2.0-data:armhf (2.33.12+really2.32.4-5, automatic), libasound2:armhf (1.0.25-4, automatic), libatk1.0-data:armhf (2.4.0-2, automatic), libfreetype6-dev:armhf (2.4.9-1.1, automatic), libflac8:armhf (1.2.1-6+b1, automatic), libqt4-svg:armhf (4.8.2+dfsg-11, automatic), libboost-chrono1.49-dev:armhf (1.49.0-3.2, automatic), x11proto-fixes-dev:armhf (5.0-2, automatic), libxrender1:armhf (0.9.7-1+deb7u1, automatic), libpthread-stubs0-dev:armhf (0.3-3+b1, automatic), libnspr4:armhf (4.9.2-1+deb7u1, automatic), libboost-math1.49.0:armhf (1.49.0-3.2, automatic), libtimedate-perl:armhf (1.2000-1, automatic), libxau-dev:armhf (1.0.7-1, automatic), dpkg-dev:armhf (1.16.12, automatic), libpthread-stubs0:armhf (0.3-3+b1, automatic), libqt4-xml:armhf (4.8.2+dfsg-11, automatic), libasyncns0:armhf (0.8-4+b1, automatic), libboost-regex-dev:armhf (1.49.0.1, automatic), yasm:armhf (1.1.0-1), libportaudio-dev:armhf (18.1-7.1), libboost-system1.49-dev:armhf (1.49.0-3.2, automatic), openmpi-bin:armhf (1.4.5-1), libtiff4:armhf (3.9.6-11, automatic), libboost-mpi-dev:armhf (1.49.0.1, automatic), libalien-sdl-perl:armhf (1.430-4, automatic), libxcomposite-dev:armhf (0.4.3-2+b1, automatic), libjasper1:armhf (1.900.1-13, automatic), libqt4-network:armhf (4.8.2+dfsg-11, automatic), libboost-random1.49.0:armhf (1.49.0-3.2, automatic), libsdl-perl:armhf (2.540-1), libjpeg62:armhf (6b1-3), libqt4-designer:armhf (4.8.2+dfsg-11, automatic), libsdl-mixer1.2:armhf (1.2.12-3, automatic), gccxml:armhf (0.9.0+cvs20120420-4, automatic), libgl1-mesa-dev:armhf (8.0.5-4+deb7u2, automatic), libboost-random1.49-dev:armhf (1.49.0-3.2, automatic), libibverbs1:armhf (1.1.6-1, automatic), libthai-data:armhf (0.1.18-2, automatic), libxtst6:armhf (1.2.1-1+deb7u1, automatic), libxrandr-dev:armhf (1.3.2-2+deb7u1, automatic), libgdk-pixbuf2.0-0:armhf (2.26.1-1, automatic), libboost-python-dev:armhf (1.49.0.1, automatic), libexpat1-dev:armhf (2.1.0-1+deb7u1, automatic), libavahi-client3:armhf (0.6.31-2, automatic), libarchive12:armhf (3.0.4-3+nmu1, automatic), libc6-dev:armhf (2.13-38+deb7u1, automatic), libqtgui4:armhf (4.8.2+dfsg-11, automatic), libboost-locale-dev:armhf (1.49.0.1, automatic), libglib2.0-0:armhf (2.33.12+really2.32.4-5, automatic), tsconf:armhf (1.0-11, automatic), libboost-graph-parallel-dev:armhf (1.49.0.1, automatic), libcairo-gobject2:armhf (1.12.2-3, automatic), x11-common:armhf (7.7+3~deb7u1, automatic), libgl1-mesa-glx:armhf (8.0.5-4+deb7u2, automatic), libmad0:armhf (0.15.1b-7, automatic), libasio-dev:armhf (1.4.1-3.2), liblapack3:armhf (3.4.1+dfsg-1+deb70u1, automatic), openmpi-common:armhf (1.4.5-1, automatic), libpixman-1-dev:armhf (0.26.0-4+deb7u1, automatic), libsm6:armhf (1.2.1-2, automatic), cpp-4.6:armhf (4.6.3-14, automatic), libxft-dev:armhf (2.3.1-1, automatic), libpulse0:armhf (2.0-6.1, automatic), libx11-dev:armhf (1.5.0-1+deb7u1, automatic), libicu-dev:armhf (4.8.1.1-12+deb7u1, automatic), libxdamage1:armhf (1.1.3-2+b1, automatic), libxml2-utils:armhf (2.8.0+dfsg1-7+nmu2, automatic), patch:armhf (2.6.1-3, automatic), libxcb-render0-dev:armhf (1.8.1-2+deb7u1, automatic), libboost-random-dev:armhf (1.49.0.1, automatic), libxfixes-dev:armhf (5.0-4+deb7u1, automatic), libqt4-script:armhf (4.8.2+dfsg-11, automatic), ca-certificates-java:armhf (20121112+nmu2, automatic), libxi6:armhf (1.6.1-1+deb7u1, automatic), libopenmpi-dev:armhf (1.4.5-1), libvorbis0a:armhf (1.3.2-1.3, automatic), libxcb1-dev:armhf (1.8.1-2+deb7u1, automatic), libfile-sharedir-perl:armhf (1.00-0.1, automatic), qt4-linguist-tools:armhf (4.8.2+dfsg-11, automatic), libqt4-scripttools:armhf (4.8.2+dfsg-11, automatic), libstdc++6-4.6-dev:armhf (4.6.3-14, automatic), libaudio2:armhf (1.9.3-5wheezy1, automatic), libxcursor1:armhf (1.1.13-1+deb7u1, automatic), libxcb-shm0:armhf (1.8.1-2+deb7u1, automatic), libavahi-common3:armhf (0.6.31-2, automatic), binutils:armhf (2.22-8, automatic), libxinerama-dev:armhf (1.1.2-1+deb7u1, automatic), libxt6:armhf (1.1.3-1+deb7u1, automatic), libxinerama1:armhf (1.1.2-1+deb7u1, automatic), libatk-wrapper-java-jni:armhf (0.30.4-3, automatic), libxext6:armhf (1.3.1-2+deb7u1, automatic), libgdk-pixbuf2.0-dev:armhf (2.26.1-1, automatic), libboost-mpi1.49.0:armhf (1.49.0-3.2, automatic), libxrandr2:armhf (1.3.2-2+deb7u1, automatic), libboost-filesystem1.49.0:armhf (1.49.0-3.2, automatic), libnss3-1d:armhf (3.14.5-1, automatic), freeglut3:armhf (2.6.0-4, automatic), libsndfile1:armhf (1.0.25-5, automatic), libboost-program-options-dev:armhf (1.49.0.1, automatic), python2.7-dev:armhf (2.7.3-6, automatic), libboost-thread1.49-dev:armhf (1.49.0-3.2, automatic), libmng1:armhf (1.0.10-3, automatic), libboost-iostreams1.49-dev:armhf (1.49.0-3.2, automatic), libgtk2.0-0:armhf (2.24.10-2, automatic), make:armhf (3.81-8.2, automatic), libbz2-dev:armhf (1.0.6-4), libmpc2:armhf (0.9-4+b1, automatic), libsdl-image1.2:armhf (1.2.12-2, automatic), libogg0:armhf (1.3.0-4, automatic), build-essential:armhf (11.5+b1), libsmpeg0:armhf (0.4.5+cvs20030824-5, automatic)
End-Date: 2014-03-17  21:02:28
Wie krieg ich eine schöne Abfrage in 'nem Einzeiler hin, damit ich nur die Paketnamen als Ergebnis kriege, um sie irgendwie an "apt-get purge" zu schicken ?
Man gibt Geld aus, das man nicht hat, um damit Dinge zu kaufen, die man nicht braucht, um damit Leute zu beeindrucken, die man nicht mag.

Benutzeravatar
ThorstenS
Beiträge: 2875
Registriert: 24.04.2004 15:33:31

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von ThorstenS » 18.03.2014 10:25:25

Speichere dir den o.g. logfileauszug in eine Datei (ich benutze für temporäre Dinge immer den Namen $$ - das entspricht der PID meiner aktuellen shell.)
Zuerst musst du die lange Zeile aufspalten, als Trenner bietet sich das Komma an.
Also: sed 's#, #\n#g' $$
Das ergibt jede Menge Zeilen, die mit automatic beginnen. Ergo übergibst du das an sort -u: sed 's#, #\n#g' $$ | sort -u
Schaut schon viel freundlicher aus! Nun musst du nur noch alles nach dem Doppelpunkt wegschmeissen und es in einer Datei schreiben:: sed 's#, #\n#g' $$ | sort -u | sed 's/:.*//' > paketliste.
Mit der Liste kannst du z.b. in einer Schleife apt-get purge aufrufen: for paket in $(cat paketliste); do apt-get purge $paket; done .

Optimierungspotential ist an dem Vorgehen massig, aber so siehst du, wie du Stück für Stück zum Ziel kommst.
Und vllt. ist dir aufgefallen, dass du beim Einsatz von sed nicht immer / als Trenner nehmen musst. Alle Zeichen sind da erlaubt. Ich nutze gerne # oder |

Benutzeravatar
pangu
Beiträge: 1400
Registriert: 15.11.2011 20:50:52
Lizenz eigener Beiträge: GNU General Public License
Wohnort: /proc/1

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von pangu » 18.03.2014 10:52:31

Hi Thorsten,

erstmal danke für deine Unterstützung. Also sieht ja ganz ok aus, aber ich hab da noch Probleme am Anfang. Da erscheint in meiner endgültigen paketliste komisches Zeichenwirrwarr, vermutlich weil irgendwas komisch abgearbeitet wurde. Du sagtest ja am Anfang, dass sich das Komma als Zeilentrenner eignet, das verstehe ich jedoch nicht.

Wenn ich das Komma als Zeilentrenner nutze, dann würde das folgende Ausgabe ergeben (Beispiel am Anfang dieser langen Liste):

Original Text:

Code: Alles auswählen

libglapi-mesa:armhf (8.0.5-4+deb7u2, automatic), libpopt-dev:armhf (1.16-7), libgtk2.0-common:armhf (2.24.10-2, automatic),
Ausgabe mit Befehl sed 's#, #\n#g':

Code: Alles auswählen

libglapi-mesa:armhf (8.0.5-4+deb7u2
automatic)
libpopt-dev:armhf (1.16-7)
libgtk2.0-common:armhf (2.24.10-2
automatic)
Ich hätte da jetzt eigentlich folgendes gemacht: alles was in Klammern steht inklusive dem darauffolgenden Komma rausschmeißen, oder besser gesagt durch Zeilenvorschub ersetzen. Wie sagt man aber dem sed, dass er das macht ? Kann das sed überhaupt (eine geöffnete Klammer von einer geschlossen Unterscheiden, und den kompletten Zwischentext verarbeiten) ?
Man gibt Geld aus, das man nicht hat, um damit Dinge zu kaufen, die man nicht braucht, um damit Leute zu beeindrucken, die man nicht mag.

Benutzeravatar
ThorstenS
Beiträge: 2875
Registriert: 24.04.2004 15:33:31

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von ThorstenS » 18.03.2014 11:38:50

Ein Zeichenwirrwar hatte ich nicht, ohne Beispiel kann ich da jetzt nicht drauf eingehen.

Aber du kannst natürlich beim zwoten sed Aufruf auch alles von Leerzeichen Klammer bis Zeilenende löschen. Das wäre dann s# (.*$##

Code: Alles auswählen

sed 's#, #\n#g' $$ | sort -u | sed 's# (.*$##'
Dann stört nur noch das eine automatic).

Dein Ansatz mit dem Löschen von Klammerauf bis Klammerzu ist auch möglich, bedarf aber einiges mehr an Aufwand, weil die REGEX schnell sehr „gierig“ wird und dir zu viel schluckt. Dir da im Detail weiterzuhelfen ist mir heute nicht möglich.

Benutzeravatar
pangu
Beiträge: 1400
Registriert: 15.11.2011 20:50:52
Lizenz eigener Beiträge: GNU General Public License
Wohnort: /proc/1

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von pangu » 18.03.2014 11:53:11

Kein Thema. Trotzdem danke. Bin grad zeitlich eingespannt, werde aber versuchen später, darauf wieder einzugehen. Irgendwie krieg ich das gebacken. Ich werd mich dann wieder hier melden ...

EDIT: So, hab eine brauchbare Lösung gefunden und zwar:

Code: Alles auswählen

awk '!/^Start|^Commandl|^End|^Upgrade:|^Error:/ { gsub( /\([^()]*\)/ ,"" );gsub(/:armhf*/,"");gsub(/ ,/," ");sub(/^Install:/,""); print}' custom-dpkg.log | xargs apt-get purge
Zuletzt geändert von pangu am 18.03.2014 13:10:11, insgesamt 1-mal geändert.
Man gibt Geld aus, das man nicht hat, um damit Dinge zu kaufen, die man nicht braucht, um damit Leute zu beeindrucken, die man nicht mag.

pferdefreund
Beiträge: 3791
Registriert: 26.02.2009 14:35:56

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von pferdefreund » 18.03.2014 13:09:37

Probier doch mal den Herren Deborphan - der räumt nach eigener Erfahrung gründlicher auf, wie autoremove bei apt-get.

Benutzeravatar
pangu
Beiträge: 1400
Registriert: 15.11.2011 20:50:52
Lizenz eigener Beiträge: GNU General Public License
Wohnort: /proc/1

Re: dpkg-Pakete rausfiltern aus /var/log/apt/history.log (aw

Beitrag von pangu » 18.03.2014 14:18:08

danke für den Tip !
Man gibt Geld aus, das man nicht hat, um damit Dinge zu kaufen, die man nicht braucht, um damit Leute zu beeindrucken, die man nicht mag.

Antworten