tar – argument list too long


If you have a lot of files in one directory and you try to process them, for example, to tar them, you will very likely get this error:

$ tar cvzf allhtml.tgz *.html
-bash: /bin/tar: Argument list too long

Try this:

$ find . -name ‘*.html’ -print > ./allfiles
$ tar -cf allhtml.tgz –files-from ./allfiles



11 Responses to “tar – argument list too long”

  1. della Says:

    or also:

    find . -name “*.html”|tar czf allhtml.tgz –files-from –

    to avoid the temp file

  2. Dennis Quek Says:

    What if I have a few directories and this adds up ?

    Should i tar all 10 directories as 10 tar files, then tar them together, or should I run find 10 times and combine the results into 1 txt tmp file. ?

    I should try them first… thanks

  3. miele Says:

    note: it is –files-from (double dash!)

  4. miele Says:

    looks like the font is not showing double dashes… so:


  5. chris Says:

    thanks miele!

  6. Jon Says:

    Here is how I piped from find to another dir.

    find . -type f -name '*_x.jpg' -print | tar -cf - --files-from - | ( cd /final/dir/ && tar xvf - )
  7. Madeira Says:

    Use -exec is pretty better!

    find . -name “*.html” -type f -exec tar -cvzf allhtml.tgz {} \;


  8. meganard Says:

    you don’t need to parse or pipe it
    tar -cvzf allhtml.tgz *.html
    to avoid “argument list too long”:
    ls *.html > htmllist.txt && tar czf allhtml.tgz –files-from htmllist.txt

  9. billy Says:

    ls.*html will also produce the argument too long error! use find instead

  10. Rogier Says:

    I’ve tried it with all of your solutions posted here and in every case, I get argument list too long. I’m trying to -only- tarring like 7000 files in one directory.. What’s up with this??

  11. haz clic aquí Says:

    Thank you a bunch for sharing this with all people you actually understand what you’re speaking about! Bookmarked. Please additionally talk over with my website =). We may have a hyperlink alternate arrangement among us

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: