Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 3491  / 2 Years ago, wed, may 11, 2022, 5:29:00

I'm trying to archive files with tar and ignoring files larger than 100MB. Is that possible?

PS: Not have to use tar.


More From » tar

 Answers
6

Yeah there are probably a few more ways of doing this but you're probably best off with find as it's so tunable.



find /path/to/dir -size -100M | xargs tar cvf archive.tar


or



tar cvf archive.tar $(find /path/to/dir -size -100M)


If there are other directories in the current folder which you do not want to archive, then use:



find /path/to/dir -maxdepth 1 -size -100M | xargs tar cvf archive.tar





Per the comments below, spaces can throw out some errors but in my testing they still seemed to get added to the archive when using the first method (a little strange in itself) but if you're worried, you can fix the find command to replace spaces with escaped versions.



As ever, there are a billion ways of doing this.



find /path/ -size -100M | sed 's/ / /g' | xargs tar cvf archive.tar

find /path/ -size -100M -exec echo '"{}"' ; | xargs tar cvf archive.tar

[#40254] Wednesday, May 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
initiallartebeest

Total Points: 24
Total Questions: 118
Total Answers: 105

Location: Venezuela
Member since Thu, Jul 15, 2021
3 Years ago
;