Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. inarray() { local n=$1 h; shift; for h; do [[ $n = "$h" ]] && return; done; return 1; } # Usage: inarray "$value" "${array[@]}"
  4.  
  5. files=("test" "foo" "foo" "bar" "test")
  6.  
  7. for filename in "${files[@]}"; do
  8.     if ! inarray "$filename" "${files[@]}"; then
  9.         filelist+="$filename""1"
  10.     else
  11.         filelist+="$filename"
  12.     fi
  13. done
  14.  
  15. echo "${filelist[*]}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement