Suchith Shivakumar
Suchith Shivakumar

Reputation: 11

Error while zipping specific files in unix

I am trying to zip all the png file in a directory using the below command, but getting error.

sudo zip pngimages.zip media/*.png
sudo: unable to execute /usr/bin/zip: Argument list too long

This directory contains more then 3000 images.

I did some research and trying to zip the images group by group—instead of zipping all files in a single go, I thought of dividing it to groups—but am new to bash script/command so am struggling with it.

Upvotes: 0

Views: 772

Answers (1)

jeremysprofile
jeremysprofile

Reputation: 11435

As seen in man zip

find . -name "*.[ch]" -print | zip source -@

which means you'd do

find media/ -name "*.png" -print | zip pngimages.zip -@

Upvotes: 3

Related Questions