Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- inarray() { local n=$1 h; shift; for h; do [[ $n = "$h" ]] && return; done; return 1; } # Usage: inarray "$value" "${array[@]}"
- files=("test" "foo" "foo" "bar" "test")
- for filename in "${files[@]}"; do
- if ! inarray "$filename" "${files[@]}"; then
- filelist+="$filename""1"
- else
- filelist+="$filename"
- fi
- done
- echo "${filelist[*]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement