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

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...