I'm working on a project that requires me to compress then relocate directories to a different location based on their last date of modification. After running the script I check to see if it worked, and upon unzipping the tar.gz using [tar -zxvf] I created everything that should be there is. I then performed the [ls] command, and saw that two additional directories had shown up after the extraction of the tar.gz, my home and downloads directories.
I'm VERY new to bash so I am probably missing something obvious but here is my script, and help would be appreciated!
cd ../Downloads
JULY=$(find . -type f -newermt 2012-07-09 ! -newermt 2012-07-10)
tar -zcvf July_compressed.tar.gz /home/josh/Downloads/${JULY}
cp July_compressed.tar.gz /home/josh/Documents/July
I need to move files from one directory into another directory based on their modification date. I'll be moving the files from the old directories to 12 new directories based on months of the year. How would include only files with set modification date in your script?
cd /path/to/old
mkdir /path/to/archives/new
JULY=$(find . -type f -newermt 2012-07-09 ! -newermt 2012-07-10)
tar cvf - $JULY | ( cd /path/to/archives/new; tar xf -)