Last active
March 19, 2018 21:43
-
-
Save thymbahutymba/c1582daa093601460731e5ab7e9f5246 to your computer and use it in GitHub Desktop.
Find which packages require the list of input packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ $# -eq 0 ] && echo "./required_by <list packages>" && exit 1 | |
list_required=(); | |
for package in $*; do | |
to_sort=($(pacman -Qi $package 2> /dev/null | grep Required | cut -c 19-)); | |
for element in ${to_sort[@]}; do | |
[[ " $* " == *"$element"* ]] && break | |
[[ " ${list_required[@]} " == *"$element"* ]] && break | |
list_required+=($element) | |
done | |
done | |
[ ${#list_required[@]} -eq 0 ] && echo "No results found" && exit 1 | |
echo ${list_required[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment