Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

World cup college
Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2009-09-12 - Email updates now available
You can now enable email updates to let you know each time you're command is commented on.
2009-07-11 - API and javascript blog widget now available
A simple API has been released, allowing commands to be retrieved in various formats. This also allows commands to be embedded on blogs/homepages.
2009-05-17 - Added duplicate suggestions to the new command form
When adding a new command, a quick background search is performed to make sure you're not duplicating a command already in the system.
2009-05-17 - Now using Gravatars for comments
Comments now display users' gravatars with the default setting as a random monster.
Hide

Tags

Hide

Functions

Move files around local filesystem with tar without wasting space using an intermediate tarball.

Terminal - Move files around local filesystem with tar without wasting space using an intermediate tarball.
( cd SOURCEDIR && tar cf - . ) | (cd DESTDIR && tar xvpf - )
2009-06-26 19:13:51
User: res0nat0r
Functions: cd tar
6
Move files around local filesystem with tar without wasting space using an intermediate tarball.

Alternatives

There are 3 alternatives - vote for the best!

Terminal - Alternatives
tar -C <source> -cf - . | tar -C <destination> -xf -
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf -
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf

Know a better way?

If you can do better, submit your command here.

What others think

Why would you do this as opposed to cp -r? Is this faster? I'm too lazy to try it out...

Comment by blue_beastie 32 weeks and 3 days ago

Well, for starters it preserves ownership, mode, timestamps, and links. Then again, so does cp -a, so I really don't know.

Comment by TheMightyBuzzard 32 weeks and 3 days ago

cp's -a switch does --recursive, --preserve=mode,ownership,timestamps,links and --no-dereference

I fail to see the point in using tar like this. Anyone? It'd make more sense if the extract command was an arg to ssh, to happen on a remote machine, and tar was set to compress the data.

Comment by tremby 32 weeks and 2 days ago

Depending on where the source and destinations live (same partition, same disk, same machine) this approach can have merit sometimes because it introduces a buffering via the pipe and the reading and writing are driven by two different tar processes rather than a single cp process. If it is faster that way, I think that would be why.

However, on the same machine I don't think this is likely to be faster, but I have definitely verified that when copying files between machines in this way (via putting an ssh user@host in front of either cmd) can be way faster than a single scp command, due to the buffering.

Comment by bwoodacre 32 weeks and 1 day ago

Oh, the old classic ;-)

Comment by oernii2 32 weeks and 1 day ago

That way more reliable when using nfs. I didn't believe it, but it happened to me that on some systems (tru64, aix, solaris) cp-ing tonns of files to nfs3 fails while tar | tar - works smoothly...

Anyway it could be that on newer release of nfs those issues won't arise.. but if you want to be sure...tar is for free :P

Comment by ioggstream 32 weeks ago

Your point of view

You must be signed in to comment.

Related sites and podcasts