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 257459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:05:55+00:00 2026-05-11T22:05:55+00:00

Scenario: I have a directory on a server that hosts my website that contains

  • 0

Scenario: I have a directory on a server that hosts my website that contains hundreds of user-submitted images. I am creating a backup script that takes all the images from the directory and compresses them into one .tar.gz file. The command I have so far is:

tar -czpf /path/to/backups/my_backup.tar.gz path/to/images/

Problem: No inside my path/to/images/ I have a directory called tmp/. When I run the command, I get a .tar.gz file containing all the image in the path/to/images/ directory and a subdirectory called tmp/.

Question: How can I get the command to skip/not include the tmp/ subdirectory in the .tar.gz file.

Thanks a million in advance.

  • 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-11T22:05:55+00:00Added an answer on May 11, 2026 at 10:05 pm

    You are looking for the --exclude argument.

    --exclude=PATTERN
    

    Some users find exclude options confusing. Here are some common pitfalls:

    • The main operating mode of tar does not act on a path name
      explicitly listed on the command line if one of its file name
      components is excluded. In the example above, if you create an
      archive and exclude files that end with *.o, but explicitly name
      the file dir.o/foo after all the options have been listed,
      dir.o/foo will be excluded from the archive.

    • You can sometimes confuse the meanings of --exclude=PATTERN and
      --exclude-from=FILE-OF-PATTERNS (-X FILE-OF-PATTERNS). Be
      careful: use --exclude=PATTERN when files to be excluded are
      given as a pattern on the command line. Use
      --exclude-from=FILE-OF-PATTERNS to introduce the name of a file
      which contains a list of patterns, one per line; each of these
      patterns can exclude zero, one, or many files.

    • When you use --exclude=PATTERN, be sure to quote the PATTERN
      parameter, so GNU tar sees wildcard characters like *. If you
      do not do this, the shell might expand the * itself using files
      at hand, so tar might receive a list of files instead of one
      pattern, or none at all, making the command somewhat illegal.
      This might not correspond to what you want.

    For example, write:

    $ tar -c -f ARCHIVE.TAR --exclude '*.o' DIRECTORY
    

    rather than:

    $ tar -c -f ARCHIVE.TAR --exclude *.o DIRECTORY
    
    • You must use use shell syntax, or globbing, rather than regexp
      syntax, when using exclude options in tar. If you try to use
      regexp syntax to describe files to be excluded, your command
      might fail.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The scenario I have access to this old linux server, that no longer receives
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Scenario: I have a console application that needs to access a network share with
Scenario: We have a great deal of server environmental information (names, IPs, roles, firewall
We have a server farm that we are slowly migrating to a new version
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
The scenario I am facing is that I have an ASP.NET web service (.NET
Scenario: We have a server where there are multiple ASP.NET websites hosted on it.
Scenario: I have imported the data from SQl Server to HDFS. The data stored
I have a rather curious scenario, which I am sure that the immense talent

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.