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

To print a specific line from a file

Terminal - To print a specific line from a file
sed -n 5p <file>
2009-10-15 11:00:48
User: Waldirio
Functions: sed
39
To print a specific line from a file

You can get one specific line during any procedure. Very interesting to be used when you know what line you want.

Alternatives

There are 3 alternatives - vote for the best!

Terminal - Alternatives
sed -n '10,20p' <filename>
2009-02-08 22:34:04
User: ergut
Functions: sed
59

Similarly, if you want to print from 10 to the end of line you can use: sed -n '10,$p' filename

This is especially useful if you are dealing with a large file. Sometimes you just want to extract a sample without opening the entire file.

Credit goes to wbx & robert at the comments section of http://www.commandlinefu.com/commands/view/348/get-line1000-from-text.#comment

awk 'NR >= 3 && NR <= 6' /path/to/file
2011-12-14 14:28:56
User: atoponce
Functions: awk
Tags: awk
7

This command uses awk(1) to print all lines between two known line numbers in a file. Useful for seeing output in a log file, where the line numbers are known. The above command will print all lines between, and including, lines 3 and 6.

sed -n '3,6p' /path/to/file
2011-12-14 15:09:38
User: flatcap
Functions: sed
Tags: sed
6

Print all lines between two line numbers

This command uses sed(1) to print all lines between two known line numbers in a file. Useful for seeing output in a log file, where the line numbers are known. The above command will print all lines between, and including, lines 3 and 6.

sed '10,20!d'
2011-03-31 15:30:24
User: tr00st
Functions: sed
3

Subtly different to the -n+p method... and probably wrong in so many ways....... But it's shorter. Just.

awk 'FNR==5' <file>
2009-10-20 22:52:41
User: dennisw
Functions: awk
1

Just one character longer than the sed version ('FNR==5' versus -n 5p). On my system, without using "exit" or "q", the awk version is over four times faster on a ~900K file using the following timing comparison:

testfile="testfile"; for cmd in "awk 'FNR==20'" "sed -n '20p'"; do echo; echo $cmd; eval "$cmd $testfile"; for i in {1..3}; do time for j in {1..100}; do eval "$cmd $testfile" >/dev/null; done; done; done

Adding "exit" or "q" made the difference between awk and sed negligible and produced a four-fold improvement over the awk timing without the "exit".

For long files, an exit can speed things up:

awk 'FNR==5{print;exit}' <file>

Know a better way?

If you can do better, submit your command here.

What others think

It might be better to have

sed -n '5{p;q}' file

so you do not read the rest of a possibly long file.

Comment by arcege 378 weeks and 6 days ago

I suggest following -

awk 'NR == 3'

This will also do the same job :-). But its shorter...

Comment by rajarshi 341 weeks and 1 day ago

I searched for "print a line number" and didn't find this. But it did show up when I was writing the command.

Comment by miniker84 61 weeks and 1 day ago

2016-1-26 xiaozhengm

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

http://www.fitflopuk.me.uk

http://www.michaelkorsukbag.co.uk

http://www.get-coachoutletonline.org

http://www.michaelkors-handbag.me.uk

http://www.runningshoes.com.co

http://www.toms-outlet.cc

http://www.ugg-boots-store.com

http://www.louboutinshoes.cc

http://canadagoose.outletmalls.us.com

http://www.nike-blazerlow.fr

http://uggs.uggaustralia.qc.com

http://www.nikestoreuk.me.uk

http://www.true-religionjeans.net.co

http://coach.outletmalls.us.com

http://www.adidasshoes.name

http://michaelkors.adsmall.us.com

http://www.hermesbelt.in.net

http://www.mulberry-bags.org.uk

http://coach.eshopping.us.com

http://louisvuitton.outletmalls.us.com

http://www.hermesuk.org.uk

http://www.katespadeoutletsale.in.net

http://toms.adsmall.us.com

http://www.fitflopssaleclearance.com

http://michaelkors.eshopping.us.com

http://ugg.adsmall.us.com

http://www.louis-vuitton-outlet.us.com

http://www.canadagoosejackets.org.uk

http://ugg.eshopping.us.com

http://www.timberlanduk.me.uk

http://www.jordan13.org

http://christianlouboutin.outletmalls.us.com

http://www.coachoutlet-storeonline.in.net

http://www.instylermax.in.net

http://www.coachfactoryoutletus.in.net

http://www.coachoutlet-storeonline.us.com

http://tiffany.outletmalls.us.com

http://www.louboutin.org.uk

http://www.monclerjacketsoutlet.us.com

http://louboutin.adsmall.us.com

http://www.louisvuitton-borse.it

http://www.mcmhandbags.name

http://www.truereligion-outlet.com

http://www.new-balanceoutlet.us

http://www.louisvuitton-sac-pascher.fr

http://www.outlet-toms.cc

http://canadagoose.shopgioia.com

http://www.coach-factory-outlet-online.us.com

http://www.top-coachoutletstore.org

http://www.edhardy-outlet.name

http://www.jordan6.net

http://www.longchamphandbags.com.co

http://www.chaussurelouboutin-pascher.fr

http://www.ghdstraighteners.me.uk

http://www.nike-tn-pascher.fr

http://www.saclongchamp-solde.fr

http://www.coachcanadaoutlet.ca

http://burberryoutlet.outletmalls.us.com

http://sunglasses.outletmalls.us.com

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

http://www.nikefreeruns.uk

http://michaelkors.outletmalls.us.com

http://www.mk-michaelkorsoutletonline.com

http://www.cheaplouisvuittonhandbags.org

http://burberry.eshopping.us.com

http://www.michaelkors-outletonlines.in.net

http://www.airjordan-pascher.fr

http://www.ralphlaurenuk.me.uk

http://www.moncler-jackets.org

http://www.adidassuperstar.co.uk

http://abercrombie.shopgioia.com

http://www.authenticlouisvuittonhandbags.net

http://www.airforce1-nike.fr

http://www.coach-factoryoutlet.cc

http://www.coachoutletonlinespick.org

http://www.coachouletbtf.com

http://rayban.eshopping.us.com

http://www.ghdhairstraighteners.com.co

http://www.ralph-lauren-pas-cher.fr

http://ralphlauren.shopgioia.com

http://rayban.adsmall.us.com

http://www.mcmoutlet.us

http://www.louisvuittonuk.me.uk

http://www.jordan-femmepascher.fr

http://www.toms.in.net

http://burberry.outletmalls.us.com

http://www.cheap-uggsonsale.in.net

http://oakley.adsmall.us.com

http://www.basketballshoes.net.co

http://ugg.shopgioia.com

http://www.raybansoutlet.in.net

http://www.mizunorunningshoes.in.net

http://www.pandoracharms.com.co

http://www.truereligion-outlet.in.net

http://www.michaelkorsoutletoff.in.net

http://www.tomswedges.in.net

http://ugg.outletmalls.us.com

http://www.cheapjordansshoes.in.net

http://www.mymichaelkorssoutlets.org

http://www.airjordan-uk.org.uk

http://www.michaelkors-handbags.me.uk

http://www.nikeblazers.me.uk

http://burberry.shopgioia.com

http://timberland.adsmall.us.com

http://coach.adsmall.us.com

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

http://www.nikesb.uk

http://www.nikerosherunwomen.me.uk

http://www.christianlouboutinuk.me.uk

http://www.ugg-boots-australia.com

http://www.adidas-trainers.me.uk

http://www.michaelkors-discount.com

http://www.polooutlet.us.com

http://www.niketrainers.com.co

http://www.airmax95.org.uk

http://www.montblancpens.us.org

http://www.adidasuk.org.uk

http://www.poloralphlauren.net.co

http://www.rolex-replicawatches.com.co

http://www.ralph-lauren.me.uk

http://www.jordan3.net

http://www.cheapwholesaleuggboots.com

http://hollister.shopgioia.com

http://www.michaelkorshandbags.cc

http://www.fitflops.in.net

http://www.snapbacks-wholesale.us

http://www.edhardyukclothing.me.uk

http://www.michaelkors-outlet-handbags.com

http://www.fitflops.us

http://www.raybans.org.uk

http://northface.outletmalls.us.com

http://nike.outletmalls.us.com

http://www.michaelkorsoutletforus.com

http://www.toryburchoutlet-sale.in.net

http://www.juicy-couture.us

http://www.raybansunglassesdeals.com.co

http://www.louis-vuittonhandbags.us

http://www.quality-outlet.com

http://christianlouboutin.eshopping.us.com

http://www.cheap-tomsoutlet.us

http://www.longchampoutlet.net.co

http://www.michaelkors-bags.me.uk

http://www.louisvuittonoutlets.name

http://www.coach-factoryoutlet.eu.com

http://www.tomsshoes.us.com

http://www.canadagooseoutlet.cc

http://canadagoose.adsmall.us.com

http://www.adidasgazelle.me.uk

http://christianlouboutin.shopgioia.com

http://www.kate-spadeoutlet.com.co

http://www.pradaoutlet.name

http://www.guccioutlet.com.so

http://www.jordan4.net

http://canadagoose.eshopping.us.com

http://www.michael-korshandbags.net.co

http://www.soccer-jerseys.us.com

http://www.nikerosheruns.me.uk

http://www.truereligion-outlet.net.co

http://oakley.shopgioia.com

http://www.sunglass-outlet.us

http://www.chiflatiron.in.net

http://www.tomsoutletstore.in.net

http://www.coachoutletstoreonlines.us

http://www.gucci-borse.it

http://www.jordan8.net

http://www.michaelkors-mkoutlet.in.net

http://www.chaussure-louboutin.fr

http://www.michaelkors-outletsale.com

http://www.michael-korsuk.me.uk

http://www.nike-airmax.org.uk

http://burberry.adsmall.us.com

http://www.montblanc-pens.name

http://www.sac-longchamppliage.fr

http://www.saclongchamp--pascher.fr

http://www.michaelkorsoutletvip.in.net

http://www.cheapjordans.com.co

http://www.louisvuitton-outletstores.org

http://www.marc-jacobs.in.net

http://www.pandorajewelryoutlet.name

http://www.christianlouboutinsell.net

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

http://rayban.shopgioia.com

http://www.oakleysunglassesfake.in.net

http://www.kate-spadeoutlet.us

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

http://www.gucci-outlet.org

http://www.adidas-shoes.me.uk

http://ralphlauren.eshopping.us.com

http://oakley.eshopping.us.com

http://www.vipmichaelkors-outletonline.com

http://www.canadagooseuk.me.uk

http://www.oakley--sunglasses.us.org

http://www.kate-spadeoutlet.in.net

http://truereligion.adsmall.us.com

http://jordan.outletmalls.us.com

http://www.guccioutlet.net.co

http://www.nikeuk.me.uk

http://www.katespadeuk.me.uk

http://www.christianlouboutinoff.us

http://www.nikecortez.com.co

http://www.nikehuarache.com.co

Comment by xiaozhengm 51 weeks and 1 day ago

Apart from engagement with Victoria's Secret type software programs, Flavia De Oliveira provides registered together with Dior, Missoni, Elie Saab, Valentino as well as. Your woman appears within advertising campaigns pertaining to Dolce & Gabbana, Salvatore Ferragamo along with.The destination of' apparel is it is actually effective ample being used for almost any sort of celebration, whether it be profession outfits or perhaps expecteded for any get together. Perhaps the ensemble will be simple as well as astounding as well as brilliant, each and every layout highlights the quantity inside a clever and sophisticated implies.If you happen to be locating developer handbags pertaining to on your own or even for re-sale and recommend to spend high-priced expenses, there are plenty connected with selections. A number of programmer bags are comfortably abandoned an array of methods and they also don't display quiting a several weeks paycheck to obtain them. Stay with the recommendations the following to view only simply just just how you might get money-saving Bags bags in a variety regarding corporations.Michael Kors timepieces are created with a person at heart and it also shows inside their very obtainable performances. You can almost never move poor strength of the provide watch : whether you're using a entire fulfill or perhaps a new fur using trousers. It's a good idea to become tasteful as well as amazing throughout almost all situations."Michael Kors is surely an organic and natural accent Bleecker Highway and all Bleecker frequenters will certainly be used satisfaction throughout put this custom and also simple fact television set identity right here. We come across your guy occasionally in the area so that it makes wonderful sensation ...Inch describes Glenda, an area person.Anybody will certainly put just one lot of amazing sort of Bags Web page that you simply or maybe can easily entail an alternative on the inside by at the same time, of which feature hobos, hand bags, clutches, consumers, in addition to flap developer grabs. It can be considerable to aid you try taking a little of your time upon work out which one-of-a-kind vogue design and style is actually absolutely to perform definitely ideal for you truly. As an example once you have one of the most recent possible ways to notice a whole car dealership to support http://www.hermesbeltsbirkinkellybag.co.uk/ all-around an individual Would certainly maybe finding a fantastic cost a lot more useful all the way down selecting a significant hobo bag and in addition have since where you can find likely time for always be involved household.For those planning to stick to established practice, selecting a straightforward oblong variety is the best thing to do. Usually do not choose the people which has a red-colored finish off or perhaps the distinctive sounds. An easy fantastic exterior is among the most effective technique to move. However, for people wanting to furthermore bring several emphasis, an amazing white-colored area upon an straightforward, rounded experience may possibly also perform very well. The entire thing will depend on your declaration you are thinking about to generate.The Skorpios variety of hand bags at this designer requires a different technique to shutting the leading. This specific significantly created scaled-down hold provides is actually a compiled or drawstring major that will advances an appealing construction for the entire bit. The actual thrown handles are usually emphasized together with steel clasps throughout gold and silver coins. This specific bag is instantly accessible in numerous tones containing dark, bright plus a aluminum rare metal.

Comment by stephanieg915 1 day ago

www.canadagoosefemmehomme2016.fr/canada-goose-mystique-femme_179.html,www.canadagoosefemmehomme2016.fr/canada-goose-victoria-parka_462.html,www.canadagoosefemmehomme2016.fr/canada-goose-toronto_259.html,www.canadagoosefemmehomme2016.fr/canada-goose-montebello-parka_81.html,www.canadagoosefemmehomme2016.fr/canada-goose-kaki_251.html,www.canadagoosefemmehomme2016.fr/parka-citadel-canada-goose_253.html,www.canadagoosefemmehomme2016.fr/adresse-magasin-canada-goose-montreal_297.html,www.canadagoosefemmehomme2016.fr/comment-reconnaitre-une-canada-goose_478.html,www.canadagoosefemmehomme2016.fr/parka-homme-canada-goose_84.html,www.canadagoosefemmehomme2016.fr/blouson-goose-canada_195.html,www.canadagoosefemmehomme2016.fr/rideau-canada-goose_303.html,www.canadagoosefemmehomme2016.fr/resolute-canada-goose_116.html,www.canadagoosefemmehomme2016.fr/bonnet-canada-goose_289.html,www.canadagoosefemmehomme2016.fr/canada-goose-marron_208.html,www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-femme-occasion_464.html,www.canadagoosefemmehomme2016.fr/canada-goose-fourrure_377.html,www.canadagoosefemmehomme2016.fr/canada-goose-taille-grand-ou-petit_112.html,www.canadagoosefemmehomme2016.fr/blouson-canada-goose-femme_143.html,www.canadagoosefemmehomme2016.fr/revendeur-canada-goose_106.html,www.canadagoosefemmehomme2016.fr/canada-goose-dawson-parka_374.html,www.canadagoosefemmehomme2016.fr/canada-goose-whistler_318.html,www.canadagoosefemmehomme2016.fr/canada-goose-chilliwack-homme_298.html,www.canadagoosefemmehomme2016.fr/entrepot-canada-goose_158.html,www.canadagoosefemmehomme2016.fr/site-officiel-de-canada-goose_435.html,www.canadagoosefemmehomme2016.fr/acheter-canada-goose-paris_406.html,www.canadagoosefemmehomme2016.fr/parka-canada-goose-prix_395.html,www.canadagoosefemmehomme2016.fr/canada-goose-the-chateau_364.html,www.canadagoosefemmehomme2016.fr/revendeur-canada-goose-france_401.html,www.canadagoosefemmehomme2016.fr/canada-goose-doudoune-sans-manche_166.html,www.canadagoosefemmehomme2016.fr/canada-goose-vrai_249.html,www.canadagoosefemmehomme2016.fr/avis-sur-canada-goose_334.html,www.canadagoosefemmehomme2016.fr/manteau-canada-goose-homme_279.html,www.canadagoosefemmehomme2016.fr/constable-canada-goose_67.html,www.canadagoosefemmehomme2016.fr/parka-canada-goose-soldes_241.html,www.canadagoosefemmehomme2016.fr/boutique-canada-goose-paris_302.html,www.canadagoosefemmehomme2016.fr/doudoune-style-canada-goose_283.html,www.canadagoosefemmehomme2016.fr/

Comment by sguerra376 20 hours ago

Your point of view

You must be signed in to comment.