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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:50:28+00:00 2026-05-10T21:50:28+00:00

I saw the following interesting usage of tar in a co-worker’s Bash scripts: `tar

  • 0

I saw the following interesting usage of tar in a co-worker’s Bash scripts:

`tar cf - * | (cd <dest> ; tar xf - )` 

Apparently it works much like rsync -av does, but faster. The question arises, how?

-m


EDIT: Can anyone explain why should this solution be preferable over the following?

cp -rfp * dest 

Is the former faster?

  • 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. 2026-05-10T21:50:29+00:00Added an answer on May 10, 2026 at 9:50 pm

    On the difference between cp and tar to copy the directory hierarchies, a simple experiment can be conducted to show the difference:

    alastair box:~/hack/cptest [1134]% mkdir src alastair box:~/hack/cptest [1135]% cd src alastair box:~/hack/cptest/src [1136]% touch foo alastair box:~/hack/cptest/src [1137]% ln -s foo foo-s alastair box:~/hack/cptest/src [1138]% ln foo foo-h alastair box:~/hack/cptest/src [1139]% ls -a total 0 -rw-r--r--  2 alastair alastair    0 Nov 25 14:59 foo -rw-r--r--  2 alastair alastair    0 Nov 25 14:59 foo-h lrwxrwxrwx  1 alastair alastair    3 Nov 25 14:59 foo-s -> foo alastair box:~/hack/cptest/src [1142]% mkdir ../cpdest alastair box:~/hack/cptest/src [1143]% cp -rfp * ../cpdest alastair box:~/hack/cptest/src [1144]% mkdir ../tardest alastair box:~/hack/cptest/src [1145]% tar cf - * | (cd ../tardest ; tar xf - ) alastair box:~/hack/cptest/src [1146]% cd .. alastair box:~/hack/cptest [1147]% ls -l cpdest total 0 -rw-r--r--  1 alastair alastair    0 Nov 25 14:59 foo -rw-r--r--  1 alastair alastair    0 Nov 25 14:59 foo-h lrwxrwxrwx  1 alastair alastair    3 Nov 25 15:00 foo-s -> foo alastair box:~/hack/cptest [1148]% ls -l tardest total 0 -rw-r--r--  2 alastair alastair    0 Nov 25 14:59 foo -rw-r--r--  2 alastair alastair    0 Nov 25 14:59 foo-h lrwxrwxrwx  1 alastair alastair    3 Nov 25 15:00 foo-s -> foo 

    The difference is in the hard-linked files. Notice how the hard-linked files are copied individually with cp and together with tar. To make the difference more obvious, have a look at the inodes for each:

    alastair box:~/hack/cptest [1149]% ls -i cpdest 24690722 foo  24690723 foo-h  24690724 foo-s alastair box:~/hack/cptest [1150]% ls -i tardest 24690801 foo  24690801 foo-h  24690802 foo-s 

    There are probably other reasons to prefer tar, but this is one big one, at least if you have extensively hard-linked files.

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

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer To mock the user property, you can do this: var… May 11, 2026 at 2:14 pm
  • added an answer What is your worker thread doing, and what is the… May 11, 2026 at 2:14 pm
  • added an answer There's two layers to this. We have most of #1… May 11, 2026 at 2:14 pm

Related Questions

I saw the following interesting usage of tar in a co-worker's Bash scripts: `tar
I am a total Groovy newbie. I saw the following code here . def
I saw some code like the following in a JSP <c:if test=<%=request.isUserInRole(RoleEnum.USER.getCode())%>> <li>user</li> </c:if>
What does the following expression return in Java? Math.max(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); I saw this question
I saw the Apple keynote address and was very impressed by the new Places
I'm writing a method to return an 'asset' row from the database. It contains
Using the tiny Diggit/Blog feature of StackOverflow described here : I would like to
I saw the following line of code: class Sample<T,U> where T:class where U: struct,
I saw the following posted by one of the fellow stackoverflower and it sort

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.