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 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

Related Questions

I saw the following bash code: at 19:00 <<! echo job 1 . I
saw the following in some .rb file name something why not using assignment like
Saw the following code snippet and I have problems to understand how it works.
I saw the following usage of jQuery selector: $('[value=]', event.target).remove(); I can guess the
I was kinda surprised when I saw following: CREATE TEMPORARY TABLE X (ID int)
I'm reading about sqlalchemy and I saw following code: employees_table = Table('employees', metadata, Column('employee_id',
I saw the following fragment of C code in a text book and it's
I recently saw the following implementation of enqueue for a BlockingQueue ( source )
On this page about hashbangs I saw the following: // get the _escaped_fragment_ parameter
I'm playing around with wpf and I saw the following article: WPF ListView Inactive

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.