lowercase to UPPERCASE - On command line


Forum: Other Help Topics
Topic: lowercase to UPPERCASE - On command line
started by: NewDude

Posted by NewDude on April 05 2006,16:11
This is for the total commandline geek...  

Is there a way to change a group of files in a Linux directory from lowercase to uppercase....  

As powerful as the command line is in Unix/Linux, I would think there was.

If not, I guess I need to write a script to do this?

I have PunBB running on my system, the styles are showing up in my browser.  I read on their forum is could a lowercase thing.  They suggested making the php, css files all uppercase.

Posted by safesys on April 05 2006,17:21
Not sure on a single command, but heres a quick and dirty bash script to do it:

#!/bin/sh
for name in `ls`
do
       mv $name `echo $name | tr 'a-z' 'A-Z'`
done

Posted by clacker on April 05 2006,17:54
safesys, you got it.  You could put what you had on a single command line:

for i in `ls`;do mv $i `echo $i | tr 'a-z' 'A-Z'`;done

Posted by NewDude on April 05 2006,20:12
Ok...  Thanks to both of you guy for replying..

So I just type for i in `ls`;do mv $i `echo $i | tr 'a-z' 'A-Z'`; in the directory that has the lowercase files?

Isn't there a wildcard and I could use to change every file in that directory...  I think there is 15 files in the root and other files in the other subdirectories...  



O I see   for i (array number is i) in 'ls';   saying every file using the ls command to list the files in the directory..  I know what echo is...   i$ is the array number which points to the value in the array, (variable)..  piped   what is tr...   some type of string maniplication function?  

command line in Linux is powerful.. amazing..   I need to learn this stuff better...

Posted by safesys on April 05 2006,21:16
don't forget you can use "man command" to get more info on specific commands

eg: man tr

Quote
NAME
      tr - translate or delete characters

SYNOPSIS
      tr [OPTION]... SET1 [SET2]

DESCRIPTION
      Translate,  squeeze,  and/or  delete  characters  from standard input,
      writing to standard output.

Posted by NewDude on April 05 2006,21:24
ok...  thanks...
\
I knew about man... but I am at work and we are forced to use evil Windoze machines, so I couldn't check it out...

Huh... but wait, I just thought of something, I do have a LIVE CD of DSL 2.2B... I wonder if I should try to use it here...  

I think I will...

Posted by NewDude on April 06 2006,00:41
Hey guys... I made a script call tocap and put it in the /bin directory..

when I try to run it, it just says...

unable to rename 'ls': No such file or directory...

It is getting confused on the ls file listing command...  help!!

Please... thanks..

Posted by mikshaw on April 06 2006,02:49
make sure ls is in backticks (`ls`), not quotes ('ls').
ADDED for great help: Using backticks will result in the output of the ls command being used in the script.  For example, if the output of ls was "foo.txt bar.txt", the script would behave like this:
for i in foo.txt bar.txt; do <commands> done
The backticks are also used in this script to retrieve a new filename for your files (echos the original and then pipes that to tr, which replaces all lowercase characters with uppercase ones).
In bash, using $(ls) achieves the same thing as `ls`.

You can replace the command altogether by using a wildcard rather than ls:
for i in *;do mv $i `echo $i | tr 'a-z' 'A-Z'`;done

Posted by NewDude on April 06 2006,13:43
I that is the problem mikshaw...

I will correct it when I get home from work.

I am positive that is the problem.

Thanks.  You are guys are really a big help.  Every time I come on this forum, I learn more and more...

Thanks again...

I thought the wild * thing would have worked to ... thanks for clearing that up.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.