Hi,
I am new to shell scripting,and i was planning to write a script that will move files which have a datetime >= currentdate-N from a source to destination folder. All configuration should be done through a properties files.
Here the value of N should be taken as 10 days(modification time)and finally the output is files are moved.
I have developed a properties file named tar_config_file1.sh and the content of this file are...
Code:
Code:
10 /home/Administrator/files /home/Administrator/output
here 10 represents 'N' DAYS , and files is the folder from where files will be picked up and output is the folder where the finally the filles will be moved.
my main script file named main1.sh which will read the properties file(tar_config_file1.sh) contents are...
Code:
#!/bin/sh
while read DAYS INDIR OUTDIR
do
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done </home/Administrator/scripts/tar_config_file1.sh
Now I want to change the structure of my properties file(archive.config) in the below format...
Code:
Code:
#############################################
#Properties file for moving files
#############################################
#This is the source directoy from where the files will be picked up
SrcDirectory=/home/Administrator/files
#This directory path should end with a slash(/)
DestDirectory=/home/Administrator/output/
#Configurable N days value is assumed here of 10 days
Days=10
Now how I will change my main scipt file...That is how my main script file will read this new properties file ...
Code:
#!/bin/sh
src_dir=$(sed '/^\#/d' archive.config | grep 'SrcDirectory' | tail -n 1 | cut -d "=" -f2-)
dest_dir=$(sed '/^\#/d' archive.config | grep 'DestDirectory' | tail -n 1 | cut -d "=" -f2-)
ndays=$(sed '/^\#/d' archive.config | grep 'Days' | tail -n 1 | cut -d "=" -f2-)
Could you please guide me on this main file How I would write the full script of the main File as I have done earlier...?