1

This is a directory structure:

enter image description here

I want to tar Directory1 with the conditions -

  1. It should include only those files that are modified in the last three days.
  2. Keep the directory structure intact.

The final tared output should be -

enter image description here

p zankat
  • 75
  • 2
  • 14
  • I noticed that you never accept answers to your questions. Please read: https://stackoverflow.com/help/someone-answers and then revisit your questions and accept the answers which were useful to you. – Aditya Jun 29 '21 at 22:27

1 Answers1

1
find directory1 -type f -mtime -4d | xargs tar -cf your_archive_name

-mtime -4d: find all files which were modified in less than 4 days

(-mtime 3d will find all files which were modified exactly 72 hours 00 minutes 00 seconds ago – this is probably not what you are asking for)

Please stay out of directory1 and directory2 while running this command.

Add -z option – tar -czf – if in addition to archiving the files, you also want to compress them.

Aditya
  • 354
  • 2
  • 6
  • 10