Post History
The solution is to use an associative array to store what you've already seen: #!/bin/bash unset seen declare -A seen for arg in "$@" do if [[ -z "${seen[$arg]}" ]] then ...
Answer
#1: Initial revision
The solution is to use an associative array to store what you've already seen: ```bash #!/bin/bash unset seen declare -A seen for arg in "$@" do if [[ -z "${seen[$arg]}" ]] then echo "Doing something omplicated with $arg" seen["$arg"]=1 fi done ``` The `unset seen` is just in case the caller had an exported variable named `seen`. The `declare -A seen` tells bash to treat `seen` as an associative array, that is, it takes arbitrary strings as index. The loop then tests for each argument whether it has not yet been seen (in which case `"${seen[arg]}"` is empty). If so, it processes it and then marks it as seen by storing something in `seen["$arg"]` (what it stores doesn't really matter as long as it is not empty; if you want, you can store additional information about the argument here, e.g. the result of processing this argument).