On Fri, 25 Mar 2016 12:47:01 -0500 Chris Bennett <chrisbenn...@bennettconstruction.us> wrote: > After I delete packages, especially pkg_delete -X, I get a long list of > instructions like: > > > -2.1.3 ------------------- > You should also run rm -rf /etc/cups/*.conf.O /var/log/cups > You should also run rm -rf /var/cache/cups > You should also run rm -rf /var/spool/cups > --- -cups-pdf-2.6.1p0 ------------------- > You should also run rm -rf /var/spool/cups-pdf/ > --- -dbus-1.10.8v0 ------------------- > Remember to update /var/db/dbus/machine-id > Remember to update /etc/machine-id > --- -dconf-0.24.0p1 ------------------- > You should also run rm -rf /etc/dconf/db/* > You should also run rm -rf /etc/dconf/profile/* > --- -foo2zjs-20140627p1 ------------------- > You should also run rm -f /usr/local/share/foo2hbpl/icm/* > You should also run rm -f /usr/local/share/foo2hiperc/icm/* > You should also run rm -f /usr/local/share/foo2hp/icm/* > You should also run rm -f /usr/local/share/foo2lava/icm/* > You should also run rm -f /usr/local/share/foo2oak/icm/* > You should also run rm -f /usr/local/share/foo2qpdl/icm/* > You should also run rm -f /usr/local/share/foo2slx/icm/* > You should also run rm -f /usr/local/share/foo2xqx/firmware/* > You should also run rm -f /usr/local/share/foo2zjs/firmware/* > You should also run rm -f /usr/local/share/foo2zjs/icm/* > --- -hplip-3.16.2 ------------------- > You should also run rm -rf /usr/local/share/hplip/data/firmware > You should also run rm -rf /usr/local/share/hplip/data/plugins > You should also run rm -rf /usr/local/share/hplip/fax/plugins > You should also run rm -rf /usr/local/share/hplip/prnt/plugins > You should also run rm -rf /usr/local/share/hplip/scan/plugins > You should also run rm -f /usr/local/share/hplip/plugin.spec > --- -hplip-common-3.16.2 ------------------- > You should also run rm -rf /var/log/hp/tmp/* > You should also run rm -f /var/log/hp/* 2>/dev/null || true > --- -net-snmp-5.7.3p6 ------------------- > You should also run rm -rf /var/net-snmp/* > --- -sane-backends-1.0.25p2 ------------------- > You should also run rm -rf /var/spool/lock/sane/* > > With this format, I have to copy/paste each rm -rf, groupdel, etc by hand. > Could these messages be changed to something easier to use like: > > > --- -hplip-3.16.2 ------------------- > You should also run > rm -rf /usr/local/share/hplip/data/firmware > rm -rf /usr/local/share/hplip/data/plugins > rm -rf /usr/local/share/hplip/fax/plugins > rm -rf /usr/local/share/hplip/prnt/plugins > rm -rf /usr/local/share/hplip/scan/plugins > rm -f /usr/local/share/hplip/plugin.spec > > This would make these commands very simple to run. > > Chris Bennett >
the magic of unix; you can work around this with some sed. # pkg_delete -X 2>&1 | tee you_should # sed -n 's/^You should also run //p' you_should >also_run # cat also_run #to verify # ksh ./also_run alternately, as non-root $ doas pkg_delete -X 2>&1 | tee you_should $ sed -n 's/^You should also run /doas /p' you_should >also_run $ cat also_run $ ksh ./also_run the above would allow doas to log each command. you could also make this into a script pkg_scrub: #!/bin/ksh raw=$TMPDIR/$$.you_should cooked=$TMPDIR/$$.also_run if [[ "$1" = all ]];then doas pkg_delete -X 2>&1 | tee $raw else doas pkg_delete $* 2>&1 | tee $raw fi sed -n 's/^You should also run /doas /p' $raw >$cooked rm -f $raw if [ ! -s $cooked ];then rm -f $cooked return 0 fi cat $cooked prompt run?"run these commands? [type 'Yes' to confirm] " if [[ "$run" = Yes ]];then ksh $cooked rm -f $cooked else echo "not running commands, saved in $cooked" fi i didn't properly test this, but you would use this like $ pkg_scrub all or $ pkg_scrub pkg1 pkg2 ...