#!/bin/ksh
#This script is use to move err files.
wk_dir=/dcds/data/receive
chg_mv()
{
echo "$name" | egrep ".Z.|gz" > /dev/null
if [ $? -eq 0 ]
then
hanghao=`echo "$name" | cut -c 3-6`
systemnu=`echo "$name | cut -c 1-2`
a=`echo $name | awk -F. '{ print $1"\."$2 }'`
b=`echo $name | awk -F. '{ print $3 }'`
c=b=`echo $name | awk -F. '{ print $4 }'`
name_new=$a"."$c"."$b
mv $name $name_new
else
hanghao=`echo $name | cut -c 3-6`
systemnu=`echo $name | cut -c 1-2`
name_new=`echo $name | cut -c 1-18`
mv $name $name_new
fi
if [ "$hanghao" == "0000" ]
then
mv $name_new $wk_dir/"$systemnu"/ctr06/
else
mv $name_new $wk_dir/"$systemnu"/4"$hanghao"/
fi
}
while true
do
clear
echo "\n"
echo " +-------------------------------------+"
echo " | 1. 按文件名移动 |"
echo " | 2. 按文件系统名移动 |"
echo " | 3. 按文件日期移动 |"
echo " | 4. 按文件日期和系统移动 |"
echo " | q. 按q退出 |"
echo " +-------------------------------------+"
read operate
case $operate in
1)
clear
echo "please input your file name(like 01000006D.s11):"
read input_name
for name in `ls "$input_name"`
do
chg_mv
done
;;
2)
clear
echo " please input your sysnumber(like 01|010740):"
read sysnumber
for name in `ls "$sysnumber"*`
do
chg_mv
done
;;
3)
clear
echo "please input your date(like 20110402):"
read file_date
for name in `ls -l | grep "$file_date"|awk '{ print $8 }'`
do
chg_mv
done
;;
4)
clear
echo "please input your system(like BS):"
read system
echo "please input your date(like 11月05):"
read file_date
for name in `ls -l "$system"* | grep "$file_date"|awk '{ print $8 }'`
do
chg_mv
done
;;
q)
exit 0
;;
*)
echo " "
echo "选择错误,请输入正确选择!"
sleep 2
;;
esac
done