Skip to content

Instantly share code, notes, and snippets.

@meleu
Last active January 27, 2020 17:14
Show Gist options
  • Select an option

  • Save meleu/66329bc06756f922401befdffd03bf48 to your computer and use it in GitHub Desktop.

Select an option

Save meleu/66329bc06756f922401befdffd03bf48 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# pacotesAusentes.sh
# https://meleu.sh/
file='file.txt'
notFoundArray=()
for pkg in "${pkg_install[@]}"; do
# -q: modo quieto; -m1: encerra na primeira ocorrência
grep -q -m1 "$pkg" "$file" || notFoundArray+=("$pkg")
done
echo "Pacotes ausentes no ${file}:"
echo "${notFoundArray[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment