Happy new year, help me with this please.
I am looping though directories picking up file name and then rename them
afterward. I am looking for the proper and easiest way of doing this:
#!/bin/sh
# Pick up all files with name starts with somefile and end with upper case
A
for FILE_NAME in $DIRECTORY/somfile*A
do
# Would like to set a variable call OUTFILE base on the same input
file name
# but end with something else instead of A, say X.
# Assume I can't use cut because I don't know the length of the file
name
# it may varies. Please HELP.
OUTPUT_FILE=??????$FILE_NAME????X
done
A step futher, say the file name indicate month, example: FILE950529 means
this file is created in May 29, 95. I like to be able to pick up 05 and
then assign
it to a variable or something. In assence, what I am trying to do is
reading a
bunch of files from 1 directory and base on the name determine where I am
going to put it and rename it. I will have 12 sub-directories ../JAN/
to ../DEC/.
So, for this example, the file FILE950529 will ended up in
../MAY/FILE950529.
How do I do it ??
Thanks for the net help.
P.S. I guess I am not real good at tr, sed and awk if I should use them
together
or soemthing to achieve this.
--------------------------------------------------------------------------
---------------
Dominic Yip - Senior System Engineer, Prism Soulution Inc.