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.

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

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
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
7
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 136 weeks 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 136 weeks 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 135 weeks and 5 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 135 weeks and 4 days ago

Oh, the old classic ;-)

Comment by oernii2 135 weeks and 4 days 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 135 weeks and 3 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts