I want to "code" a shell script which will do the following:

  • check for new folders in foler XYZ , will make a cron that opens the script every 30mins
  • if NEW folders found = use RAR and rar those folders like they are named . XYZ Main Folder:

-Blububb Changed: 7.03.2014 -> create rar -> Blubb.rar

for all in `find / -name "rpc-backup*" -type d -print`
#create archive
rar -a -k -v250000k /home/testuser/rar1.rar /home/testuser/rpc-backup1


So you see I dont have much so far , I need first of all a find command which looks only for new files or changed after the date (7.03.2014) , then also my rar process has to rar every folder he gets individual and not just one big rar where all my folders are in, i want a single rar for every single folder.

  • Just one question about your choice of tools. If you are on linux, why rar? Why not tar.gz or something standard like this? rar is not part of the core utilities, it's missing from most repositories, it has the wrong license and it is almost never used on linux. Not to mention it breaks file ownership.
    – orion
    Commented Mar 10, 2014 at 11:08

2 Answers 2


for finding a file or folder that is new, find is your friend

find /folder/you/want -type d -ctime +10 -exec (your rar here)

look up your man pages for details on find, my examples above do not make sense

man find

#Creating a sample file with the reference date as its time stamp
touch -t 1403070000 /home/scripts/test/sample_file

for i in `find /home/scripts/test/ -type d -newer /home/scripts/test/sample_file -print`

# find /home/scripts/test/ -type d -newer /home/scripts/test/sample_file -print 
# displays all directories that are created after the reference date


        rar -a -k -v250000k /home/scripts/test/$i.rar /home/scripts/test/$i


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .