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

  • Home
  • SEARCH
  • 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 4549662
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:23:29+00:00 2026-05-21T16:23:29+00:00

The following is a snippet from a script I have that tries to tar

  • 0

The following is a snippet from a script I have that tries
to tar up all php files in a subdir. It tries to use the ‘–include’ parameter
but does not seem to work (output is from ‘set -x’ in bash)

+ find . -name '*.php'
./autoload.php
./ext/thrift_protocol/run-tests.php
./protocol/TBinaryProtocol.php
...
./transport/TTransportFactory.php
+ tar -cvjf my.tar.bz2 '--include=*.php' .
+ set +x

The find found several php files but tar does not seem to see them. If I take out the --include all files are tarred.

I know I can use find to feed a list
(find . -name '*.php' -print0 | tar -cvjf "my.tar.bz2" --null -T -), but whats wrong with the --include param?

  • 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-21T16:23:29+00:00Added an answer on May 21, 2026 at 4:23 pm

    Actually I just looked into tar(1) on my freebsd system and I found an –include option (earlier I had looked on some old man page online). The --include options is quite powerful. Here are some examples

    These are the files

    cnicutar@uranus ~/tar_test $ ls -1
    a.c
    b.c
    x
    

    Simple tar, archive everything

    cnicutar@uranus ~/tar_test $ tar -cvf archive1.tar *
    a a.c
    a b.c
    a x
    

    Archive only C files

    cnicutar@uranus ~/tar_test $ tar -cvf archive2.tar --include='*.c' *
    a a.c
    a b.c
    

    So what is probably wrong in your script is that you give tar . instead of .* as the last argument.

    EDIT

    I have tried it and was surprised. The behavior of tar(1) is unexpected but (I believe) intended. The man page says:

    Process only files or directories that match the specified pattern.
    

    So when you specify the pattern it filters out any directories that don’t match it. So if your directories don’t happen to have that extension (it’s valid but uncommon) it won’t descend into them (even if deep inside there might be “interesting” files).

    So in conclusion I believe it would be best to use another way to recursively enumerate + filter files.

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

Sidebar

Related Questions

I have the following code snippet from my PowerShell script that... Loops through a
I have the following snippet below from my script that's using a WebRequest to
The following snippet from RuntimeUtil.java from jlibs guarantees GC that garbage collection is done.
I have the following snippet from my code: switch ($extention) { case gif: $src
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
Hey all, the following is a snippet of code taken from the unix ptx
I have the following very simple code snippet which is loaded from a separate
I have the following query that I'm executing using a Python script (by using
I have the following snippet of PowerShell script in my profile: . (join-path (split-path
I have the following snippet that toggles padding when hovering (see example here ):

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.