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 merge from sorted by
Terminal - Commands tagged merge - 9 results
pdftk *.pdf cat output merged.pdf
2014-03-02 01:53:37
User: o0110o
Functions: cat
2

Merge Multiple PDFs In Alphabetical Order

pdfunite 1.pdf 2.pdf 3.pdf result.pdf
pr -m -t file1 file2 ...
mergepdf() { gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf "$@" }
2011-07-28 11:12:15
Functions: gs
1

This is an expansion on a previous entry, which I've wrapped in a function and placed in my profile. The "$@" is a positional parameter, much like "$*", but the parameters are passed on intact, without interpretation or expansion; so you can simply call the function like this:

mergepdf *

This will output a merged PDF of all PDFs in the current directory. Alternatively, you can simply list them like so:

mergepdf 00.pdf 01.pdf 02.pdf ...

N.B. Passing a wildcard will merge all PDFs in the current directory in name order, e.g. 00.pdf 01.pdf aa.pdf ab.pdf

pdftk input1.pdf input2.pdf cat output output.pdf
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf ...
svn merge -c -REV
2010-06-21 15:11:13
User: shadycraig
Functions: merge
Tags: svn merge revert
1

This command can be used to revert a particular changeset in the local copy.

I find this useful because I frequently import files into the wrong directory. After the import it says "Committed revision 123" or similar. to revert this change in the working copy do:

svn merge -c -123 .

(don't forget the .) and then commit.

paste file1 file2 fileN > merged
2010-03-12 16:34:48
User: polaco
Functions: paste
Tags: merge paste join
3

Merge files, joining line by line horizontally.

Very useful when you have a lot of files where each line represents an info about an event and you want to join them into a single file where each line has all the info about the same event

See the example for a better understanding

/usr/local/bin/svn merge -r {rev_num}:HEAD https://{host}/{project}/branches/{branch_name} .
2009-04-03 15:43:32
User: kamiller
Functions: merge
Tags: svn merge
1

This will merge all of the changes from {rev_num} to head on the branch to the current working directory