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.


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.

Universal configuration monitoring and system of record for IT.
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

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

sort lines by length

Terminal - sort lines by length
awk '{print length, $0;}' | sort -nr
2009-10-07 16:32:27
User: ashawley
Functions: awk sort
6
sort lines by length

Alternatives

There are 6 alternatives - vote for the best!

Terminal - Alternatives
awk 'length>72' file
2009-09-10 05:54:41
User: haivu
Functions: awk
Tags: awk
16

This command displays a list of lines that are longer than 72 characters. I use this command to identify those lines in my scripts and cut them short the way I like it.

perl -lne '$l{$_}=length;END{for(sort{$l{$a}<=>$l{$b}}keys %l){print}}' < /usr/share/dict/words | tail
perl -C -e 'print for sort { length $a <=> length $b or $a cmp $b } <>' < /usr/share/dict/words | tail
2011-10-20 01:43:25
User: dbr
Functions: cmp perl sort
3

making it "sound" more "natural" language like -- additionally sorting the longest words alphabetically:

this approach is using:

* to get at all lines of input

* post-"for" structure

* short-circuit-or in sort: if the lengths are the same, then sort alphabetically otherwise don't even evaluate the right hand side of the or

* -C sets all input and ouput channels to utf8

while read i; do [ ${#i} -gt 72 ] && echo "$i"; done < /path/to/file
2014-03-20 12:27:06
User: flatcap
Functions: echo read
1

Filter out lines of input that contain 72, or fewer, characters.

This uses bash only. ${#i} is the number of characters in variable i.

perl -nle 'print length,"\t",$_ if length > 37' < /path/to/input/file
2014-03-20 09:44:41
User: fibo
Functions: perl
0

Note that in the command N is, for instance, 37.

Know a better way?

If you can do better, submit your command here.

What others think

MK can be a extravagance brand name which has basically gained it's great credibility. Awards including the CFDA Could Designer of year within 1999, the actual CFDA Males Design Programmer of this year inside 2003 along with the CFDA Life Good results Give in 2010 have established the globe exactly why the particular MK's series is often a power being reckoned using. professionally requires a operations obligation in the page layout of all items. Maybe for this reason the manufacturer has really started to grow as well as entice to help this sort of huge target audience. Their view selection features suffered a feeling of high quality and beauty that can fascination supporters for countless years ahead.Take bags are a couple of the most flexible bags around. The actual Handbags family members is just not proof against in which outline. The actual Carriers Obvious Bag is out select for your the autumn months. The particular fantastic factor regarding carry bags is perhaps all the appliance they might be used by. Anybody can store a few career data file files, his or her Apple macbook or perhaps a sweater with the much cooler night time. They give a far more popular procedure for retaining your computer or laptop around and then the basic laptop computer bags provided on those major computer merchants.Also come from the Oughout.Utes., Mentor, the North National market place, nevertheless likewise it's main celebration. 2013 personal yr concluding Dec 28, The year 2012, released inside The month of january this coming year, Private coach, but it really drops small: Q2 every 3 months revenue greater 4 percent in order to A dollar.A few billion, One dollar.Half a dozen billion diminished than the current market expected.Anyone fully grasp which you fantastic extremely crucial just consider overnight, just be sure you acquire enough get some good sleep. Certainly, the not necessarily virtually plenty of relax will definitely forms create reduction in viewpoint, that could harmed your also of the offers that you specially purchase. Receive a at least 8-10 time associated with the rest the night time well before when a perception photograph.The newest speak within the runway may be the Outlet Resort 2014 Series. It contains a number of the Hands Springs Modern day with a Twenty-first century handle smooth 1970's size. Kors will take natural hues and also ensures they are come to life with sparkle.The hottest porcelain watches for women out of this variety contains a incredible mother-of-pearl face that is typically studded having uric acid to include even more interest these kinds of alluring designer watches. A number of the the majority of gorgeous watches by his or her assortment attribute this MK Blossom Rare metal Enjoy along with the MK White Earthenware Watches for female using Mommy associated with Globule Face in addition to Silver Glitz.Initially starting with their own clothing collection, they before long became a brand for you to reckon in the model marketplace. Most of the substantial full price clothing outlets world-wide starting attiring his / her apparel brand for ladies so because of this their level of popularity extended. Gals all through the entire world experienced the tactic the clothing could fit their body and very quickly this individual expanded an exponent platform that showcased one of the most important celebs throughout the world.Sewn Bags -- Some form of padded motorola clutch or perhaps mini-handbag brings an excellent pose http://www.hermesbeltsbirkinkellybag.co.uk/ to an otherwise serious outfit. Look for impressive exceptional styles besides crayon-inspired tones for any use young person years days to weeks. This particular crucial Fendi Stitched Baguette will certainly attain potential buyers down on the excellent start off.

Comment by stephanieg915 1 week ago

www.canadagoosefemmehomme2016.fr/doudoune-femme-canada-goose_103.html

www.canadagoosefemmehomme2016.fr/canada-goose-bomber-chilliwack_119.html

www.canadagoosefemmehomme2016.fr/prix-d-une-canada-goose-au-canada_175.html

www.canadagoosefemmehomme2016.fr/canada-goose-payer-en-plusieurs-fois_152.html

www.canadagoosefemmehomme2016.fr/canada-goose-dawson-parka_374.html

www.canadagoosefemmehomme2016.fr/canada-goose-grise_80.html

www.canadagoosefemmehomme2016.fr/vetement-canada-goose_368.html

www.canadagoosefemmehomme2016.fr/canada-goose-moncler_415.html

www.canadagoosefemmehomme2016.fr/canada-goose-bebe_436.html

www.canadagoosefemmehomme2016.fr/veste-canada-goose-homme-pas-cher_199.html

www.canadagoosefemmehomme2016.fr/chapeau-canada-goose_238.html

www.canadagoosefemmehomme2016.fr/canada-goose-victoria_293.html

www.canadagoosefemmehomme2016.fr/canada-goose-rouge_118.html

www.canadagoosefemmehomme2016.fr/homme-canadian-goose_180.html

www.canadagoosefemmehomme2016.fr/canada-goose-montreal_267.html

www.canadagoosefemmehomme2016.fr/canada-goose-prix-usa_359.html

www.canadagoosefemmehomme2016.fr/canada-goose-trilium_181.html

www.canadagoosefemmehomme2016.fr/canada-goose-femme-trillium_201.html

www.canadagoosefemmehomme2016.fr/doudoune-homme-canada-goose_366.html

www.canadagoosefemmehomme2016.fr/blouson-goose-canada_195.html

www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-bomber-femme_458.html

www.canadagoosefemmehomme2016.fr/canada-goose-pas-cher-homme_161.html

www.canadagoosefemmehomme2016.fr/canada-goose-quebec_125.html

www.canadagoosefemmehomme2016.fr/blouson-canada-goose_156.html

www.canadagoosefemmehomme2016.fr/parka-montebello-canada-goose_379.html

www.canadagoosefemmehomme2016.fr/canada-goose-style_105.html

Comment by sguerra376 4 days ago

www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-bomber-femme_458.html

www.canadagoosefemmehomme2016.fr/canada-goose-a-montreal_306.html

www.canadagoosefemmehomme2016.fr/pas-cher-canadian-goose_219.html

www.canadagoosefemmehomme2016.fr/canada-goose-victoria-parka_462.html

www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-rose_421.html

www.canadagoosefemmehomme2016.fr/canada-goose-montebello-noir_170.html

www.canadagoosefemmehomme2016.fr/canada-goose-prix-canada_277.html

www.canadagoosefemmehomme2016.fr/doudoune-style-canada-goose-femme_388.html

www.canadagoosefemmehomme2016.fr/canada-goose-homme-chilliwack_233.html

www.canadagoosefemmehomme2016.fr/canada-goose-femme-chilliwack_113.html

www.canadagoosefemmehomme2016.fr/canada-goose-ottawa_412.html

www.canadagoosefemmehomme2016.fr/canada-goose-fourrure-amovible_71.html

www.canadagoosefemmehomme2016.fr/canada-goose-boutique-paris_167.html

www.canadagoosefemmehomme2016.fr/adresse-magasin-canada-goose-montreal_297.html

www.canadagoosefemmehomme2016.fr/prix-d-une-canada-goose-au-canada_175.html

www.canadagoosefemmehomme2016.fr/parka-montebello-canada-goose_379.html

www.canadagoosefemmehomme2016.fr/canada-goose-dawson-parka_374.html

www.canadagoosefemmehomme2016.fr/revendeur-canada-goose-france_401.html

www.canadagoosefemmehomme2016.fr/magasin-canada-goose_93.html

www.canadagoosefemmehomme2016.fr/canada-goose-the-chateau_364.html

www.canadagoosefemmehomme2016.fr/canada-goose-outlet-france_122.html

www.canadagoosefemmehomme2016.fr/canada-goose-verte_154.html

www.canadagoosefemmehomme2016.fr/langford-canada-goose_290.html

www.canadagoosefemmehomme2016.fr/canada-goose-suisse-prix_276.html

www.canadagoosefemmehomme2016.fr/doudoune-goose-canada_292.html

Comment by sguerra376 3 days ago

http://www.canadagoosefemmehomme2016.fr/canada-goose-kensington-parka-femme_448.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-site_385.html

http://www.canadagoosefemmehomme2016.fr/blouson-goose-canada_195.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-enfant_264.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-rundle_453.html

http://www.canadagoosefemmehomme2016.fr/doudoune-goose-canada_292.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-homme-pas-cher_440.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-toulouse_459.html

http://www.canadagoosefemmehomme2016.fr/doudoune-homme-canada-goose-pas-cher_204.html

http://www.canadagoosefemmehomme2016.fr/revendeur-canada-goose-france_401.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-femme-doudoune_101.html

http://www.canadagoosefemmehomme2016.fr/manteau-canada-goose-femme-pas-cher_472.html

http://www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-femme-noir_114.html

http://www.canadagoosefemmehomme2016.fr/lodge-hoody-canada-goose_133.html

http://www.canadagoosefemmehomme2016.fr/acheter-canada-goose-paris_406.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-femme-courte_322.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-femme-pas-cher_139.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-the-chateau_364.html

http://www.canadagoosefemmehomme2016.fr/canada-gooser_220.html

http://www.canadagoosefemmehomme2016.fr/canada-goose-resolute_66.html

Comment by sguerra376 2 days ago

Your point of view

You must be signed in to comment.