In PC DOS environment, this command can rename all files ,which begin with
"r" and end with extension CPP in uppercase, into lowecase.(e.g.
rMYFILE.CPP rmyfile.cpp)
How can i do it in Unix Shell?
Thanks!
How can i do it in Unix Shell?
Thanks!
First, create a for loop that matches each of the files to be renamed. For
example:
for VAR in r*.CPP ; do
... some commands go here
done
Note that for each iteration of the loop, VAR contains a different file
name - successively taken from the set of files matching the pattern r*.CPP.
Now, inside the loop, define a new variable, NEWVAR, which is transformed
(using tr and/or sed) to reformat the filename as desired. Because you don't
want to translate the initial 'r', I created an intermediate variable
(TMPVAR) that holds only that portion of the filename we wish to modify. For
example:
TMPVAR=`echo $VAR | sed 's/^r\(.*\)/\1/'
NEWVAR=`echo $TMPVAR | tr 'a-z' 'A-Z'`
After these two commands (and still inside the loop) you can now rename the
files with the mv command. The old file name is in $VAR and the new file
name is in $NEWVAR For example,
mv $VAR $NEWVAR
NOTE: Some of the above syntax only works in Bourne shell scripts, so make
sure it runs in Bourne shell (#!/bin/sh), not C shell.
HTH,
-Bob
Andover, MA
Quote:> In PC DOS environment, this command can rename all files ,which begin with
> "r" and end with extension CPP in uppercase, into lowecase.(e.g.
> rMYFILE.CPP rmyfile.cpp)
> How can i do it in Unix Shell?
> Thanks!
Here's one way,
$ typeset -l J
$ for I in `ls r*.CPP`; do J=$I; mv $I $J; done
> In PC DOS environment, this command can rename all files ,which begin with
> "r" and end with extension CPP in uppercase, into lowecase.(e.g.
> rMYFILE.CPP rmyfile.cpp)
> How can i do it in Unix Shell?
> Thanks!
1. cpp gone in 4.0 (Was: cpp vs. m4 for .s files)
This is true, but cpp is also shipped in /usr/ccs/lib/cpp because the
regular preprocessor changed the way it handles some constructs. If
you have code that uses cpp on non-C files, you need to use this
instead of cc -P or cc -E, since the other way will fail (see gdb
or emacs for an example of this).
--
Dell Computer 9505 Arboretum Blvd Austin, TX 78759-7299
2. Patch 2.5.48 ALSA Cirrus Logic 4281
3. cpp: Out of file descriptors?!
5. KDE2.2: kprocess.cpp does not compile on Solaris7
6. Problem with elapsed time functions
7. XLC cpp
8. Kde 3.1 Question: fonts in Kde2-programs display only Courier
10. CPP-Symbols
12. KOFFICE Install Errors "mico-cpp"