Linux command ‚tar‘ – how to tar bzip old files in yearly groups

If you want to create a tar archive in Linux that contains all files from a given year (say from 01-Jan to 31-Dec) you can do it by combining find with tar so that only files from that time range are included

Here’s the general approach:

Example: Create a tar file for all files from 01-Jan-2000 to 31-Dec-2000

# cd /path/to/directory
# find -type f -newermt 2000-01-01 ! -newermt 2001-01-01 | tar -cjf /elsewhere/2000.tar.bz2 -T –

Leave a Reply

You must be logged in to post a comment.