Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I start on shell and i don't know how to compress a folder including just the .jpg and .jpeg files.

Anyone can help me?

Thank you

share|improve this question
1  
Can you please clarify the question? Do you mean to just "include" .jpg files in the archive without compression operations performed on those files, while compressing all other files? –  cjc Nov 3 '11 at 12:03
add comment

2 Answers

$ tar cvf jpeg.tar $(find /path/to/folder -iregex ".*\.jpe?g")
$ find /path/to/folder -type f -iregex ".*\.jpe?g" | xargs tar cvf jpg.tar
share|improve this answer
    
I would prefer the latter version as the first one might fail in case of many files to compress. This is avoided by the second variant which uses xargs to overcome that problem. (@quanta: a little bit of explanation would be helpful in a case like that). –  SvW Nov 3 '11 at 11:31
add comment

Go to folder

zip archive *.jpg *.jpeg

else, from anywhere

zip archive /path/to/folder/*.jpg /path/to/folder/*.jpeg

archive is the output file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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