Shell: dramatically increased performance and simplicity of pacman-files.
parent
12700c1dea
commit
4c2bea8bcb
|
@ -46,7 +46,7 @@ pacman-files()
|
||||||
echo -e " $1 [-n] PACKAGES"
|
echo -e " $1 [-n] PACKAGES"
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo -e " default:\tDisplay file size of PACKAGES."
|
echo -e " default:\tDisplay size of files in PACKAGES."
|
||||||
echo -e " -h:\t\tDisplay this help."
|
echo -e " -h:\t\tDisplay this help."
|
||||||
echo -e " -n:\t\tSort by size."
|
echo -e " -n:\t\tSort by size."
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,7 @@ pacman-files()
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local RESULT_HUMAN="$(du -bh $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u) | eval ${OPTION_SORT})"
|
du -bch $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u) 2>/dev/null | eval ${OPTION_SORT}
|
||||||
local RESULT="$(du -b $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u))"
|
|
||||||
echo "${RESULT_HUMAN}"
|
|
||||||
|
|
||||||
echo "$RESULT" | awk -F "[[:alpha:]]" '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL/1024)}'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## Retrieve official packages list.
|
## Retrieve official packages list.
|
||||||
|
@ -222,12 +218,12 @@ pacman-size()
|
||||||
## Print total size.
|
## Print total size.
|
||||||
echo "$RESULT" | awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}'
|
echo "$RESULT" | awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}'
|
||||||
|
|
||||||
## One line version. Approximately same performance. Note the combinaion of
|
## One line version. Approximately same performance. Note the combinaion of
|
||||||
## 'tee' and >(awk ...) to write the detailed list to standard output and to
|
## 'tee' and >(awk ...) to write the detailed list to standard output and to
|
||||||
## pass it to awk.
|
## pass it to awk.
|
||||||
# eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
# eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
||||||
# '$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3 \
|
# '$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3 \
|
||||||
# | tee >(awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}')
|
# | tee >(awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}')
|
||||||
|
|
||||||
_pacman_unset_vars
|
_pacman_unset_vars
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue