Identify files in cwd which only differ in case


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.