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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.
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

Count lines of code across multiple file types, sorted by least amount of code to greatest

Terminal - Count lines of code across multiple file types, sorted by least amount of code to greatest
find . \( -iname '*.[ch]' -o -iname '*.php' -o -iname '*.pl' \) -exec wc -l {} \; | sort
2010-04-28 07:18:21
User: rkulla
Functions: find wc
2
Count lines of code across multiple file types, sorted by least amount of code to greatest

Gives you a nice quick summary of how many lines each of your files is comprised of. (In this example, we just check .c, .h, .php and .pl). Since we just use wc -l to count, you'll just get a very rough estimate of how many lines of actual code there are. Use a more sophisticated algorithm instead if you need to.

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
find . \( -iname '*.[ch]' -o -iname '*.php' -o -iname '*.pl' \) -exec wc -l {} + | sort -n
2010-05-03 00:16:02
User: hackerb9
Functions: find sort wc
5

The same as the other two alternatives, but now less forking! Instead of using '\;' to mark the end of an -exec command in GNU find, you can simply use '+' and it'll run the command only once with all the files as arguments.

This has two benefits over the xargs version: it's easier to read and spaces in the filesnames work automatically (no -print0). [Oh, and there's one less fork, if you care about such things. But, then again, one is equal to zero for sufficiently large values of zero.]

find . \( -iname '*.[ch]' -o -iname '*.php' -o -iname '*.pl' \) | xargs wc -l | sort -n
2010-04-30 12:21:28
User: rbossy
Functions: find sort wc xargs
Tags: find count
0

find -exec is evil since it launches a process for each file. You get the total as a bonus.

Also, without -n sort will sort by lexical order (that is 9 after 10).

Know a better way?

If you can do better, submit your command here.

What others think

zhengjx 20170413

http://www.chromehearts.com.co

http://www.adidasnmdrunner.us.com

http://www.atlantafalconsjerseys.us

http://www.adidasnmd.co

http://www.adidasneo.us.com

http://www.michaelkors-outletsonline.us.com

http://www.nikedunks.us.org

http://www.nike-airforce1.us.com

http://www.kobe-shoes.us.com

http://www.nikerosheone.co.uk

http://www.nikerosheone.us.com

http://www.longchampbags.us.org

http://www.cheapauthenticjordans.us.com

http://www.nikeairforce1.us.com

http://www.michaelkors-factoryoutlet.com.co

http://www.linksoflondonus.com

http://www.chromeheartsonlinestore.us.com

http://www.nikezoom.us.com

http://www.michael-kors-handbags.com.co

http://www.adidasultraboost.us.org

http://www.adidasstansmith.uk

http://www.hardenshoes.us.com

http://www.nike-air-huarache.uk

http://www.jewelrypandora.in.net

http://www.cheaprealjordans.us.com

http://www.lebron13.us.com

http://www.thelightupshoes.us.com

http://www.nikezoom.me.uk

http://www.outletonline--michaelkors.com

http://www.truereligion-outlets.us.com

http://www.nike-airmax2017.us.com

http://www.airjordanretro.uk

http://www.huarachesshoes.co.uk

http://www.yeezy-shoes.org

http://www.toryburchshoes.co.uk

http://www.rosherun.us.com

http://www.yeezy-boost.us.com

http://www.cheapretro-jordans.com

http://www.cheap--jordans.us.com

http://www.fitflops.cc

http://www.pandorabracelet.in.net

http://www.outlettimberland.us.org

http://www.adidassuperstar.org.uk

http://www.yeezyboost.com.co

http://www.airhuaraches.org.uk

http://www.airmaxthea.us.com

http://www.kobesneakers.com

http://www.huaracheshoes.uk

http://www.michaelkors-outletonlines.us.com

http://www.michael--korsoutlet.us.org

http://www.nikemercurial.us.com

http://www.yeezy-shoes.us

http://www.lebronjames-shoes.us.com

http://www.pandorauk.uk

http://www.michaelkorsoutletstoreonline.com.co

http://www.kobebasketballshoes.us.com

http://www.kobeshoes.uk

http://www.michaeljordanshoes.us.com

http://www.michaelkors-outletfactory.us.org

http://www.boostyeezy.us.com

http://www.longchamp.me.uk

http://www.airhuarache.uk

http://www.yeezy-boost350.us.com

http://www.charmspandora.in.net

http://www.reebokoutlet.us.org

http://www.linksoflondon.us.com

http://www.hermes-belt.us.com

http://www.michaelkors-outletstore.us.org

http://www.yeezyboost.in.net

http://www.hermes-belt.co.uk

http://www.adidastubular.us.com

http://www.cheapbasketballshoes.us.com

http://www.ultraboost.us.com

http://www.authenticjordanscheap.us.com

http://www.adidasneo.org.uk

http://www.jordanshoes.com.co

http://www.lacostepoloshirts.us.com

http://www.hoganoutlet.cc

http://www.yeezyboost350.com.co

http://www.adidasstansmith.us.com

http://www.kobebasketballshoes.net

http://www.bootstimberland.co.uk

http://www.chrome-hearts.us.com

http://www.ledshoes.us.com

http://www.outletonline-michaelkors.us.org

http://www.lacoste-outlet.us.com

http://www.jordanshoes.uk

http://www.mkoutlets.us.com

http://www.cheap-airjordans.us.com

http://www.nmdadidas.us.com

http://www.yeezyshoes.uk

http://www.nikepolo.us

http://www.michaelkorsoutletonlinesale.com.co

http://www.longchamphandbagsoutlet.us.org

http://www.nike-huarache.me.uk

http://www.bagslongchamp.uk

http://www.patriotsjerseys.us.com

http://www.michaelkors-outletstore.com.co

http://www.adidassuperstar.us.com

http://www.michael-kors-handbags.org.uk

http://www.adidasultra.us.com

http://www.huarachesshoes.uk

http://www.michaelkors-outletstore.us.com

http://www.kyrieirving-shoes.us.com

http://www.adidastubular.co.uk

http://www.michaelkors-outletonlinestore.com.co

http://www.lacosteonline.cc

http://www.kyrie3.us.com

http://www.jordansforcheap.us.com

http://www.adidasnmd.uk

http://www.truereligionjeans.uk

http://www.airjordan.us.com

http://www.michaelkors-outletonlinestore.us.org

http://www.outletlongchamp.us.com

http://www.toryburchshoes.us

http://www.michaelkorshandbagssale.us.org

http://www.michaeljordanshoes.net

http://www.lebron14.us.com

http://www.air-max.us.com

http://www.fitflops-saleclearance.us.com

http://www.longchamphandbags.us.org

http://www.louboutinshoes.uk

Comment by zhengjx 32 weeks and 1 day ago

[url=http://www.nikesport.shoes/]Nike Air Max Shoes[/url]

[url=http://www.mkloves.com/]Cheap Michael Kors Handbags[/url]

[url=http://www.mkwao.com/]Coach Handbags Outlet[/url]

[url=http://www.nikesport.shoes/]Nike Air Max Shoes Outlet[/url]

[url=http://www.mkwao.com/]Cheap Crossbody Bags[/url]

[url=http://www.mkloves.com/]Cheap Coach Bags[/url]

[url=http://www.nikesport.shoes/]Nike Air Max Shoes Online[/url]

[url=http://www.mkloves.com/]Cheap Coach Bags sale[/url]

[url=http://www.mkwao.com/]Cheap Coach Handbags sale[/url]

Comment by chensolo 14 weeks and 1 day ago

In the library to see a book, feel a little mean. 'Do not die', a Japanese riding a bike with about seven years time around the world. There are a lot of interesting on the way,http://www.nikesport.shoes/">Nike Air Max Shoes there have been a variety of challenges of life events, I sincerely admire him.

Seven years can occur a lot of things, such as marriage and children, promotion salary increase, but the author chose to ride a bike tour. For the author, he moved to be very comfortable to finish this life, but he chose the http://www.mkloves.com/">Cheap Michael Kors Handbagsadventure, in fact, nothing more than a restless heart prompted him to do this thing, there is a great courage, So that he can give up high salaries, decided to travel around the world.

Not just me, in this world most people lack is the courage of this one.http://www.mkwao.com/">Coach Handbags Outlet Many people do not want to change, there is no courage to change, and then drift, become a member of the mortal beings, life has passed, no merit, mediocrity.

Comment by chensolo 14 weeks and 1 day ago

Your point of view

You must be signed in to comment.