Quote:
|
Originally Posted by cgjoker my idea didn't work... ill have to rethink this approach...
for fnow in `find . -name "0*.*"`
do
if [ $fnow ]
then
case "$fnow" in
[0-9][aA-zZ]*) now=`echo $fnow | cut -b3- | sed -e 's/.dat//g'`;;
[0-9][0-9]*) now=`echo $fnow | cut -b4- | sed -e 's/.dat//g'`;;
*) echo "$dt: no files found, continuing processing" ;;
esac
mv "$fnow" /directory/"b$fnow""_$date".dat
done |
problems:
find command will find files beginning with 0 only.
if [ $fnow ] should be if [ -f $fnow ] ( you want only normal files ).
case is built to recognize file names that find will never find.
cut -b3 - why do you want the 3rd byte? aren't you looking for the first and/or second bytes?
Quote:
for ffile in *
do
if [ $ffile ]
then
fflag=`echo $ffile | cut -c1-2`
case "$ffile" in
[0-9][aA-zZ]*) newffile=`echo $ffile | cut -b3- | sed -e 's/.dat//g'`;;
[0-9][0-9]*) newffile=`echo $ffile | cut -b4- | sed -e 's/.dat//g'`;;
*) echo "$dt: no files found, continuing processing"
;;
esac
find . -name "$fblfile" -mtime +${fflag} -exec mv {} /directory/"b$newfile""_$date".dat \;
echo "$dt: ${ffile} file found equal to 1
done
|
Better. But...
if [ $ffile ] doesn't make sense (same reason as above).
fflag=`echo $ffile | cur -c1-2` gets the first two characters. Your case, again, isn't really set up to match the possibilities correctly.
Here's a shot:
for file in *
do
if [ -f $file ]
then
case "$file" in
[0-9][A-z]*) agedays=$(echo $file | cut -c1) ;; # one digit
[0-9][0-9]*) agedays=$(echo $file | cut -c1-2) ;; # two digits
*) agedays=999 ;;
esac
if [ $agedays -ne 999 -a $agedays -gt 0 ]
then
do whatever you need to do
fi
fi
done
case "$file"