Posted By

tm on 12/18/09


Tagged

Bash files case equivalent


Versions (?)

Identify files in cwd which only differ in case


 / Published in: Bash
 

  1. # Find all files (and directories) in the current directory (cwd) which are
  2. # 'equivalent' wrt. case. E.g. foo =~ FOO =~ foO ...
  3. shopt -s nocasematch; unset a
  4. for f in *; do
  5. for e in "${a[@]}"; do
  6. if [[ "$f" == "$e" ]]; then
  7. echo "'$f' equivalent to '$e'"
  8. # break out and continue with next file
  9. continue 2
  10. fi
  11. done
  12. # file is not yet in array -> add it
  13. a+=($f)
  14. done

Report this snippet  

You need to login to post a comment.