Hi All,
I am creting archive script in which i need to split the source file's to different target folder's based on the input file name first character.
Input1.txt -- will contains file names that are needs to be Archive.
Input1.txt
A1213355
B2255666
C2254555
A6655444
C5566445
Source folder will have many different source files , from the source file i needs to archive only the files which are listed in the Input1.txt
sample source folder files
A1213355
A6565656
B2255666
B5555555
C2254555
A6655444
C5566445
my desired output is based on input1.txt:
AFolder-- should have archived files [A1213355,A6655444]
BFolder-- should have archived files [B2255666]
CFolder-- should have archived files [C2254555,A6655444,C5566445]
my code is like:
#!/usr/bin/ksh
CURRDATE=`date +%Y%m%d%H%M%S`
Filest="A:AFolder B:BFolder C:CFolder"
for a in ${Filest}
do
FOLDER=`echo ${CURRENT_SET} | cut -f2 -d:`
FILE_NAME=`echo ${CURRENT_SET} | cut -f1 -d:`
echo ${FOLDER}
echo ${FILE_NAME}
done
cat $SOURCE_FOLDER/input1.txt |
while read N
do
tar -cvf $FOLDER/$N"_"$CURRDATE.tar $SOURCE_FOLDER/$N
done
Could you please guide me how to achieve this task...:wall:
Thanks in advance...