Hello,
I am new to shell scripting..i need your help.
i have the delete the log files which are present in the specific path .i have the rules as below.
1)In Path1 i need to delete all the files which are present
2)in Path2 i need to keep 1 month of data and delete the rest of the data
3)in Path3 i need to keep 2 weeks of data and delete all the files.
4)in Path4 i need to keep 1 year of data and delete all the files which are more than one year.
5)in path5 i need to keep last 2 backups which are kept .
i need a generic code .i have tried using the below code but failed to execute can any one of you please help me in completing my code.
#!/bin/bash
function processpathinput2 () {
targetFolder=$1
input2=$2
if [[ "$input2" == "*m" ]]
then
echo "Remove files under $targetFolder which are $input2 old"
elif
if [[ "$input2" == "*d" ]]
then
echo "Remove files under $targetFolder which are $input2 old"
elif
if [[ "$input2" == "*y" ]]
then
echo "Remove files under $targetFolder which are $input2 old"
else
echo "Invalid input"
fi
}
path="/home/path/tmp/dele:1d"
My idea is based on the letter m,y,d it should calculate and delete the files .