Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upper/Lower--case problems....

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
I have a certain set of directories which are non-standard regarding their case assignments and I need them to be all uppercase so that another process can parse through the data and build an entirely new set of standardized data. But I am having a problem when attempting to change the lower to upper case directories. It changes, but then I get the same directory underneath it (lowercase) with a duplicate of the data underneath that.

Example:

Starting directory structure:

Hello/*.txt
how/*.txt
aRe/*.txt
YOU/*.txt
ToDay/*.txt

I have tried both of the following with the same results:

for DIR in `ls -1`
do
/usr/bin/mvdir ${DIR} `echo ${DIR}|/usr/bin/tr '[:lower:]' '[:upper:]'`
done

OR:

/usr/bin/ls -1 > list
/usr/bin/awk '{print toupper($0)}' list > list2
COUNT=1
FCOUNT=`/usr/bin/cat list2|/usr/bin/wc -l`
let FCOUNT=FCOUNT+1
while [ ${COUNT} -ne ${FCOUNT} ]
do
DIRA=`/usr/bin/head -${COUNT} list|/usr/bin/tail -1`
DIRB=`/usr/bin/head -${COUNT} list2|/usr/bin/tail -1`
/usr/bin/mvdir ${DIRA} ${DIRB}
let COUNT=COUNT+1
done

And I end up with this:

HELLO/*.txt
hello/*.txt
HOW/*.txt
/how/*.txt
ARE/*.txt
/are/*.txt
YOU/*.txt
/you/*.txt
TODAY/*.txt
/today/*.txt


Could someone please point out the error that I am making when attempting to run either of these processes, from what I can tell, this shouldn't be happening.

SHELL: KSH93
OS: SCO UNIXWARE 7.1.1

Thanks in Advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top