Skip to content

Instantly share code, notes, and snippets.

@mjf
Created April 26, 2012 12:15
Show Gist options
  • Save mjf/2499208 to your computer and use it in GitHub Desktop.
Save mjf/2499208 to your computer and use it in GitHub Desktop.
Script to tell whether any of it's argument repeats
#! /bin/sh
# If no arguments are given, return true.
if [ $# -eq 0 ]
then
exit 0
fi
# Test whether any of the arguments repeats.
while [ $# -gt 0 ]
do
_CURRENT="$1"
shift
for _ITEM in "$@"
do
if [ "$_CURRENT" = "$_ITEM" ]
then
exit 0
fi
done
done
# If not, return false.
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment