input=(apple banana apple cherry banana date apple)
dedupe() {
declare -A seen=()
local out=()
for item in "$@"; do
if [[ -z "${seen[$item]+x}" ]]; then
seen[$item]=1
out+=("$item")
fi
done
printf '%s\n' "${out[@]}"
}
dedupe "${input[@]}"
# apple
# banana
# cherry
# date
Create a free account and build your private vault. Share publicly whenever you want.