> for pkg in $@ ; do > - echo "$pkg" >> /var/lib/apt-install/queue > + if ! grep -q "$pkg" /var/lib/apt-install/queue; then > + echo "$pkg" >> /var/lib/apt-install/queue > + fi > done I believe this should grep with "^$pkg$" to avoid matching substrings.