Hi Gurus,
I am trying to cp files from source to destination from file test but
somehow it doesn't work.
Here is my sample test file:
cat Sample
----------------------------------------------------------------------
/store/sharedstore/03-02-03-08-20-47/file1.doc
/store/sharedstore/03-02-03-08-20-47/file2.doc
/store/sharedstore/03-02-03-08-20-47/test1.doc
/store/sharedstore/03-02-03-08-20-47/test2.doc
/store/sharedstore/03-02-03-08-20-47/sample1.doc
/store/sharedstore/03-02-03-08-20-47/smple2.dwg
-------------------------------------------------------------------------
I have to copy files from Sample file say
/store/sharedstore/03-02-03-08-20-47/file1.doc to another location
/Backupstore/sharedstore/03-02-03-08-20-47/file1.doc and so on...
The destination location changes only the first mount point.
Any Help is greatly appreciated.
Regards
#!/bin/ksh
filename=Sample
# Check if we can read the file ...
if [ ! -r "$filename" ]; then
echo "Cannot read $filename."
exit 1
fi;
if [ -f makedirs ]
then
rm makedirs
fi
for line in `cat $filename`
do
srcfile=`echo $line`
destpath=`dirname $line`
echo $destpath >>makedirs
sed 's/\/store/\/pstore/' makedirs > dirs
cat dirs | while read file
do
if [ ! -d "$file" ]
then
echo "mkdir -p $file"
fi
echo "cp $srcfile $file"
done
#cp $srcfile $destfile
done