shell script to selectively tar directory based on date

hye everybody :slight_smile: ,
i'm new to the scripting world.. hope you guys can help me out with this one..

i'm trying to identify any directory under /tmp/saya that is created more than one day from the current date..

e.g, today is March 14, so any directory that has time stamp March 13 backwards, i want to tar it and put under /tmp/awak..

this is the script that i created (without the date)

### PART 1 : TO TAR FILE IN /tmp/saya AND PUT IN /tmp/awak ###
cd /tmp/saya
for file in *
do
if [[ -d $file ]]
then
tar -cvf /tmp/awak/$file.tar $file
fi
done

thanks a lot!
-fara

find . -mtime +1 -exec ls -l {}\;

that would list out the files older than one day
Therefore, you want to work that (or similar) into your process

Since you have the $file, maybe replace the . above with the $file?

hi joeyg, thanks a lot! :slight_smile:

this is what i did..

### PART 1 : TO TAR FILE IN /tmp/saya AND PUT IN /tmp/awak ###
cd /tmp/saya
for file in *
do
if [[ -d $file ]]
then
find . -mtime +1 -exec tar -cvf /tmp/awak/$file.tar $file {} \;
fi
done