[Gllug] Perl scripting challenge

- Tethys tethys at gmail.com
Wed Oct 4 15:47:01 UTC 2006


On 10/4/06, Simon Morris <simon.morris at cmtww.com> wrote:

> Problem there is I don't know what the duplicated filenames are...
> Apparently on this filesystem (I'm about to inherit a problem unless I
> can deflect it away :-) ) they had a history of creating filenames that
> are identical apart from case.

No problem:

#!/bin/sh

find "${1:-.}" -type d -print | while read dir
do
    preserve_case=$(ls -a1 "$dir" | wc -l)
    ignore_case=$(ls -a1 "$dir" | sort -f | uniq -i | wc -l)
    if [ "$preserve_case" != "$ignore_case" ]
    then
        echo "Directory has duplicate filenames: $dir"
    fi
done

Tet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list