From f00faa05220e5e4c3c90b8bc17074d5ee7bbee03 Mon Sep 17 00:00:00 2001 From: Harvie Date: Fri, 4 Jun 2010 15:21:02 +0200 Subject: [PATCH] Some improvements in pacorphans.sh --- bash/pacorphans.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bash/pacorphans.sh b/bash/pacorphans.sh index 1db7382..a506697 100755 --- a/bash/pacorphans.sh +++ b/bash/pacorphans.sh @@ -1,11 +1,23 @@ #!/bin/bash -time /usr/bin/pacman -Ql | cut -d ' ' -f 2- | sort -u > db.txt +db="$(mktemp)" +fs="$(mktemp)" +orphans="$(mktemp)" + +echo "[*] Saving list of files owned by pacman to $db ..." >&2 +time /usr/bin/pacman -Qlq | sort -u > "$db" +echo >&2 +echo "[*] Saving list of files in filesystem to $fs ..." >&2 time find /arch /bin /boot /etc /lib /opt /sbin /usr 2>/dev/null | while read i; do if [ ! -d "$i" ]; then echo "$i" fi; -done | sort -u > fs.txt -time comm -23 fs.txt db.txt > non-db.txt +done | sort -u > "$fs" +echo >&2 +echo "[*] Comparing db ( $db ) and fs ( $fs ) ..." >&2 +time comm -23 "$fs" "$db" | tee "$orphans" +rm -- "$db" "$fs" +echo >&2 +echo "[!] List of files not owned by any package were saved to: $orphans" >&2 #test it: -#cat non-db.txt | while read i; do pacman -Qo "$i" 2>&1; done | tee test.txt +#cat "$orphans" | while read i; do pacman -Qo "$i" 2>&1; done | tee /tmp/orphantest.txt -- 2.30.2