Re: lowercase to uppercase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



RedHat wrote:
Hello.
I am looking for a way to permanently change the contents of a directory from lowercase to uppercase.

Every time this question comes up, several people post scripts that will happily overwrite or otherwise mangle your data. I suggest this one, which I believe to be safe:

#!/bin/sh

for ORIGINAL in *[[:upper:]]*; do
        NEW=`echo -- $ORIGINAL | tr '[:upper:]' '[:lower:]'`
        if [ -d "$NEW" ] ; then
                echo -- "$ORIGINAL" cannot be lowercased because "$NEW" is a directory
        elif [ -e "$NEW" ] ; then
                if ( cmp -- "$ORIGINAL" "$NEW" ); then
                        rm -f -- "$ORIGINAL"
                else
                        echo -- "$ORIGINAL" cannot be lowercased because "$NEW" exists
                fi
        else
                mv -i -- "$ORIGINAL" "$NEW"
        fi
done



--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux