#!/bin/bash
#Files modified in the last 24 hours
cd /files/docs
find . -type f -mtime -1 -exec cp -pr {} /files/bak/ \;
cd /files/docs
#Directories modified in the last 24 hours
find . -type d -mtime -1 > files001.txt
sed 's/.\//\/files\/docs\//g' files001.txt > files002.txt
sed -i '1d' files002.txt
for file in $(<files002.txt); do cp -pr "$file" /files/bak; done
cd /files
tar -cf bak.tar bak