Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Ahmed Talaat

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Avoiding tar's (or any other commandline's) argument list too long error

When you try to tar a large number of files (cp, mv, or anything else) you may hit the limit of ARG_MAX. You can overcome this by generating a list of files then feeding it to tar as follows:

# generate the file list
find -iname '*.ext' > fileList.txt

#run tar passing it the file list
tar czvf archive.tar.gz --files-from fileList.txt

# a shorthand of this would be:
find . -name '*.ext' -print | tar -cvzf archive.tar.gz --files-from -
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS