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

Commands tagged compare from sorted by
Terminal - Commands tagged compare - 6 results
rsync -v -r --size-only --compare-dest=../A/ B/ C/
2013-09-10 21:41:16
User: knoppix5
Functions: rsync
7

Assumed dir A, B, C are subdirs of the current dir

Exact syntax of the command is:

rsync -v -r --size-only --compare-dest=/path_to_A/A/ /path_to_B/B/ /path_to_C/C/

(do not omit end-slashes, since that would copy only the names and not the contents of subdirs of dir B to dir C)

You can replace --size-only with --checksum for more thorough file differences validation

Useful switch:

-n, --dry-run perform a trial run with no changes made

convert image1 image2 -resize '400x300!' MIFF:- | compare -metric AE -fuzz '10%' - null:
2012-04-17 11:25:34
User: dooblem
2

Outputs the number of different pixels.

2 params to increase tolerance:

* thumbnails size

* fuzz, the color distance tolerance

See http://en.positon.org/post/Compare-/-diff-between-two-images for more details.

ls -Rl dir1/ > /tmp/dir1.ls; ls -Rl dir2/ > /tmp/dir2.ls; meld /tmp/dir1.ls /tmp/dir2.ls
2012-03-04 13:06:55
User: joeseggiola
Functions: ls
0

Compare the ls -Rl output of two directories in meld (you can also use diff -y instead of meld).

diff -dbByw $COLUMNS FILE1 FILE2
2012-02-28 03:19:20
User: DewiMorgan
Functions: diff
Tags: diff compare
0

The normal output of 'diff' is a wonderful thing. But just sometimes, you want something that is a little more... well... readable.

This is that command.

-d - (optional) find the minimal set of changes

-b - (optional) ignore changes in the amount of whitespace

-B - (optional) ignore changes that just insert or delete blank lines

-y - this is where the magic happens! Use the side-by-side output format.

-w $COLUMNS - more magic! Instead of using 80 columns, use the current width of the terminal.

gdiff --unified=10000 input.file1 inpute.file2 | egrep -v "(^\+[a-z]|^\-[a-z])"| sort > outputfile.sorted
2009-06-18 20:35:00
User: slashdot
Functions: egrep sort
-1

This commands will make it easier to select only common items between two files being compared. If your lines start with things other than lowercase a-z, adjust this Regex appropriately. Number of lines in the output has been set to no more than 10000, and should be adjusted as needed.