How to make a tar of all files modified in the last 30 minutes

We'll be using two basic commands from the unix toolbox: find & xargs. Mastering these commands is essential to realize the power of shell programming.

Imagine you have been merging file changes from directory dir1 to dir2, and now you want to create a tar file with the modified files... but there were many changes and you didn't make a list (why would you anyway?). Just run the following command (in :

$ cd dir2
$ find . -type f -cmin -30 | xargs tar zcvf updated_files.tar.gz

Let me add something else about a the find command:

The find command uses the following strategy: find descends through a hierarchy of files, matches the files that meet specified criteria, and performs some actions.

In our case, we just default to the print action.

Next, xargs converts input from the standard input into arguments for the specified command. It would be like manually typing the following command:

$ tar zcvf updated_files.tar.gz file1 file2 subdir1/file2 ...

PD: I'm using these while updating an old Drupal website to the last bugfix release.