Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7614137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:19:35+00:00 2026-05-31T02:19:35+00:00

Please consider this snippet: tar -Oxvf archive.tgz | grep something or this: tar tf

  • 0

Please consider this snippet:

tar -Oxvf archive.tgz | grep something

or this:

tar tf archive.tgz > /tmp/x && tar -Oxvf archive.tgz -T /tmp/x | grep something

versus this:

tar tf archive.tgz | xargs -I{} tar -Oxvf archive.tgz {} | grep something

First two snippets are very fast and similar, while third is ~40 times slower (this index is relative to archive contents I guess). Why is that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:19:36+00:00Added an answer on May 31, 2026 at 2:19 am

    The key here is your use of -I{} in xargs. The man page says:

       -I replace-str
    

    Replace occurrences of replace-str in the initial-arguments with names read from standard input. Also, unquoted blanks do not
    terminate input items; instead the separator is the newline character.
    Implies -x and -L 1.

    The implied -L 1 makes xargs run your tar -Oxvf archive.tgz {} once per file in the archive, rather than running tar once to extract all the files listed on xargs’ stdin.

    Simplified example of the difference:

    $ (echo foo; echo bar)|xargs -I{} echo {}
    foo
    bar
    
    $ (echo foo; echo bar)|xargs echo 
    foo bar
    

    Fixed:

    tar tf archive.tgz | xargs tar -Oxvf archive.tgz | grep something
    

    Note however that the output of this will not be the same as what you get using xargs -I{} if the file names given to xargs are not in tar file order (i.e. the same order that tar t lists them in). The xargs -I{} version will ouptut the files in the order you provided to xargs, whereas this version will output them in tar file order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()
Please consider this HTML and CSS snippet: #container { border: 1px solid red; height:
Please consider this code: System.Linq.Expressions.Expression<Func<tbl, bool>> exp_details = r => r.ID_Master == Id &&
Please consider this snippet (related to How is 13 % 64= -13 ) if(extension_loaded('GMP'))
Please consider this code snippet: private static void doSomething(Double avg, Double min, Double sd)
Please consider this code snippet: var ul = $(.list_b).find(li).remove().end(); $.each(Sites, function (index, value) {
Please consider this snippet: http://fruple.com/kemper/test/categorie.html Firefox screenshot: Chrome screenshot why are some of the
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Please consider this site . I'm having trouble stretching the submenu list items in
Please Consider this scenario: We have a base class called clsMain : class clsMain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.