I have an account on AWS and I use S3 for storing data. I have commands that will enable me to zip data files like so:

data.zip s3_dir/level-1/level-2/*/*/data.txt

But there are, say, 50 or more levels. I want to zip all the data.txt files together from all levels. I'm not as sharp on my Bash as I could be so any help would be much appreciated.

link|improve this question

does it have to be a zip file? Can you use gzip instead? It's not the same format, but I know it can be recursive with the -r option... – tjameson Apr 18 '11 at 22:36
feedback

1 Answer

up vote 3 down vote accepted
find some/dir -name data.txt | zip -@ data.zip
link|improve this answer
This is perfect... Actually, right after I posted this question, a buddy gave me some hints... The command I used was: find /some/path -name '*.txt' | xargs -n 100 zip all_data.zip – nicorellius Apr 18 '11 at 22:39
What's the -@ for BTW? – nicorellius Apr 18 '11 at 22:39
It tells zip to get the list of filenames from stdin, so that you don't need to use xargs. – Ignacio Vazquez-Abrams Apr 18 '11 at 22:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.