Hi All,
i want to move logs files from one path(source path) to another path(destination path). This source path and destination path is present in one text file. as::
source_path=abc/xyz
source_path=pqr/abc
desination_path=abcd/mlk
so i read this file and stored paths in different variables.i have multiple source path so i stored it in a varible which acts as array. as below::
sourcePaths=`grep source_path myfile |cut -d= -f2`
destPath=`grep destination_path myfile |cut -d= -f2`
and i have only one destination path where i want to move all these files. Now i want to travel through all these source path, find the logs file with specific extension, zip these all files and move to destination path. i use loop to retrieve data from sourcePaths variable(this is just trial). as:;
for i in $sourcePaths
do
echo $i
done
Can anybody help me in this.
Thanks a lot for your reply Guys.Now i want to add some filter in this. I want to move files from Source path which are 10 days old,and i want to delete these files from source path after moving. Please help
Just one more question!! What if i want to store this zip file with name which contain time stamp,so that there will be no duplication of file name at destination path.
Hi All,one more question.When i am zipping the file with above option,it is creating subfolder in zip file according to its path.ie. if i am zipping logs files from src/int/xlog/abc, and when i unzip this zip file,these newly craeted zip file contents logs files in src/int/xlog/abc/abc.zip. i dont want this.what i want is that this zip file directly content abc.zip. Not in sub folder.
Hi Guys, i am back with one more question.Here using below script i am able to create filename of zip as base pathname.e.g.xyz.zip and abc.zip as per my above given path using below code::
timestamp=`date +%Y%m%d_%H%M%S`
zipFile=$destPath/$(basename $sourcePath).$timestamp.zip
But now i want to create this file name(i.e.Zip file name) more specific depends on its source path.Like if my text file contents
source_path=obj/imp/backup/logs/db1
source_path=obj/res/input/int/db2
desination_path=abcd/mlk
Now i want to create zip file name something like this.
backup_logs_db1.zip
input_int_db2.zip
means i want to use last three directory name to create new zip file name. It is provided that source path in text file contents more than three directory name.
So can anybody help me in this. Thnaks in advance!!!