WebHosting

Monday, January 14, 2013

Automatically Finding files of specific size of type or modified date and adding to tar


Refer following command for your specific need:

#All files of size greater thab 1Gb

find / -type f -size +1048576 | xargs tar -czf myfile.tgz

#All files modified one day before

find / -type f -mtime -1 | xargs tar -czf myfile.tgz

#All files modified one day before and size more than 1Gb

find / -type f -mtime -1 -size +1048576 | xargs tar -czf myfile.tgz

------------------------ OR ------------------------------------



#All files of size greater thab 1Gb

find / -type f -size +1048576 -exec tar -cvvfp /some/path/some.tar {} \;

#All files modified one day before

find / -type f -mtime -1 -exec tar -cvvfp /some/path/some.tar {} \;

#All files modified one day before and size more than 1Gb

find / -type f -mtime -1 -size +1048576 -exec tar -cvfp /some/path/some.tar {} \;



--------------------------- Some other operations -------------------------

#Find and move file to yourspecified location

find / -type f -mtime -1 -size +1048576 -exec mv /yourlocations {} \;


Note : If you want to search these file in specific directory the specify that directory path after find instead of "/" of give "." for current location.

+ afer mtime means search files older than the specified time
- afer mtime means search files newer than the specified time and older current time

You can try many other option and explore imagination

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

OBS Browser Source Not Working? How to Interact With Web Pages Inside OBS Studio

If you're using OBS Studio to display a website, YouTube page, dashboard, live poll, chat widget, or web application, you may notice so...