2013年8月28日星期三

Help write a linux shell script . About the SIM number section of

I've got this one demand segment on SIM card , but I are not familiar with linux script , so here please heroes help ! Requirements are as follows :
linux in the path / export/SIM1 / , there may be several folders 135,138,139 and so on. In 135 there may be 1111,2222 ( four of ) equal segments need to determine what number section ! ! ! ! ! in 138,139 will also true. For example, section 1111 exists under 135 , it is determined whether the number under paragraph No. There are other segments such as 3333 ( also four ) . such as the presence paragraph No. 3333 , it is determined whether there is day 3333 generated files , such as 2013-08-21.sh. If there is then copied to the / export/SIM2 / appropriate folder. But / export/SIM2 / path is empty , the need to / export/SIM1 / determine if there is a corresponding folder is not created , if there is no need to create . . To the more urgent , please help heroes ! ! ! Brother thanks thanks ~ ~ ~

------ Solution -------------------------------- ------------

#!/bin/bash

DIR1=/export/SIM1
DIR2=/export/SIM2

for i in ${DIR1}/*
do
if [ -d $i ]
then
for j in $i/*
do
if [ -d $j ]
then
echo $j
echo $j/`date +%Y-%m-%d`.sh
if [ -f $j/`date +%Y-%m-%d`.sh ]
then
echo $j/`date +%Y-%m-%d`.sh
tmp=${j/SIM1/SIM2}
mkdir -p ${tmp}
cp $j/`date +%Y-%m-%d`.sh ${tmp}
fi
fi
done
fi
done


if you can use
------ For reference only ----------------------------- ----------
If the echo values ​​are in line with expectations , then , echo can be deleted
------ For reference only ----------- ----------------------------




gray often thank you , I used your script as a foundation , modify has become what I want. Thanks ~ ! !

没有评论:

发表评论