Operating System - HP-UX
1832907 Members
3909 Online
110048 Solutions
New Discussion

lower case/upper case question

 
SOLVED
Go to solution
Luca Frigatti
Contributor

lower case/upper case question

Hi All!!!
I've the following question.
I write a shell script that copy a list of file from one directory to another.
This files came from a Windows system and when I transfer them from Windows to UNIX the name of the files are in the lower case.
I need to copy these file to another directory in upper case. For example:
in /home/luca/app/ I've the following file : abcde.txt.
I need to copy this file in the directory /home/luca2/final like ABCDE.txt.
Is there a function to help me?
Does anybody have avy suggestion? Any idea?
Thanks in advance for your help and your support.
Regards.
Luca
4 REPLIES 4
Steve Steel
Honored Contributor

Re: lower case/upper case question

Hi


Standard shell typeset. see man sh-posix


-u Convert all lowercase characters to uppercase characters.
The lowercase -l option is turned off. Flagged as
uppercase.


typeset -u lala=lala
echo $lala
LALA


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Leif Halvarsson_2
Honored Contributor

Re: lower case/upper case question

Hi

One method for copy files to new directory,translating lower to upper in filename but keep lower in extension.

file=/home/luca/app/abcde.txt
cp $file /home/luca2/final/`basename $file .txt | tr '[:upper:]' '[:lower:]'`.txt
Leif Halvarsson_2
Honored Contributor
Solution

Re: lower case/upper case question

Sorry

I had shifted upper and lower.

file=/home/luca/app/abcde.txt
cp $file /home/luca2/final/`basename $file .txt | tr '[:lower:]' '[:upper:]'`.txt


harry d brown jr
Honored Contributor

Re: lower case/upper case question

W$ (windows) could care less what the case of the filename is, and if unix receives the file names in lowercase, then this is GOOD!

If you really want to then you need something like this:

cd /home/luca/app;find . -type f | awk '{loname=$1; upname=toupper($1); doit="mv
" loname " /home/luca2/final/" upname; system(doit);}'


live free or die
harry
Live Free or Die