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

Print a row of characters the width of terminal

Terminal - Print a row of characters the width of terminal
printf -vl "%${COLUMNS:-`tput cols 2>&-||echo 80`}s\n" && echo ${l// /-};
2016-09-25 10:37:20
User: AskApache
Functions: echo printf
4
Print a row of characters the width of terminal

Unlike other methods that use pipes and exec software like tr or sed or subshells, this is an extremely fast way to print a line and will always be able to detect the terminal width or else defaults to 80. It uses bash builtins for printf and echo and works with printf that supports the non-POSIX `-v` option to store result to var instead of printing to stdout.

Here it is in a function that lets you change the line character to use and the length with args, it also supports color escape sequences with the echo -e option.

function L() { local l=; builtin printf -vl "%${2:-${COLUMNS:-`tput cols 2>&-||echo 80`}}s\n" && echo -e "${l// /${1:-=}}"; }

With color:

L "`tput setaf 3`="

1. Use printf to store n space chars followed by a newline to an environment variable "l" where n is local environment variable from $COLUMNS if set, else it will use `tput cols` and if that fails it will default to 80.

2. If printf succeeds then echo `$l` that contains the chars, replacing all blank spaces with "-" (can be changed to anything you want).

From: http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html http://www.askapache.com/linux/bash-power-prompt.html

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives

Know a better way?

If you can do better, submit your command here.

What others think

If you'd prefer to order via phone, feel free to call us up between 9 am to 5 pm EST on any weekday and our trained customer service associates will help you make the right http://www.vetsonwhl.co.uk/vetsonwhl.html and place an order seamlessly. We deliver very fast, via USPS and EMS. One http://www.watchesshopsuk.co.uk/ that we leave to you is the price! Check out the prices and you won't believe that these http://www.replicawatchesukshop.co.uk/ are available at these prices! Father's Day is on the way and it is time that we http://www.rolexreplicasonline.us/ our fathers back for all the love and affection they have showered on us. Maybe some sons think that http://www.luxuryrex.us/ is adamant and had told he that he would never accept a costly gift from his son. Taking his viewpoints into consideration I think maybe go in for the best Hublot replica watches that money could purchase.

Comment by yanzhongr5 3 weeks and 6 days ago

http://www.thetotome.com cheap michael kors watches uk

http://www.dorwotruet.com wholesale michael kors watch

http://www.mobincrazy.com Australia Michael Kors Official Site

http://www.tobentheth.com michael kors factory store

http://www.forlobagsc.com Cheap Mk Bags Outlet

http://www.topbagstar.com discount michael kors purse

http://www.topbagsshow.com authentic michael kors wholesale

http://www.bestluxubags.com discount michael kors store

http://www.cutebagsale.com clearance michael kors purses

http://www.bagsluxubuy.com coach outlet purses on sale

http://www.bagsluxusell.com wholesale coach bags

http://www.bagsluxuzone.com black coach duffle bag

http://www.bestjewelrybazaar.com PANDORA Clearance

http://www.bestjewelrystars.com Cheap Pandora Charms

http://www.bestjewelryshoppe.com PANDORA US Online Store

http://www.bagsluxubazaar.com coach discount handbags

http://www.voguejewelryplaza.com Pandora Jewelry Specials

http://www.starsboostmart.com Yeezy 350 ebay event

http://www.starsboostbuy.com YEEZY BOOST Official site

http://www.starsboostzone.com Men Yeezy Boost 350

http://www.starsboostcenter.com Adidas YEEZY 350 BOOST

http://www.starsboostpower.com NMD Runner Men/Women Shoes

http://www.starsboostforce.com Adidas NMD

http://www.voguejewelryshoppe.com buy pandora online

http://www.starsboostbazaar.com Adidas NMD outlet store

http://www.topboostmart.com Nmd Runner Blue Men

http://www.topboostonline.com Nmd Triple Black Adidas

http://www.voguejewelrymall.com Pandora Jewelry US

http://www.topjewelrybazaars.com wholesale pandora bracelets

http://www.voguejewelryboutique.com buy pandora charms online

http://www.voguejewelrymarket.com cheap pandora beads

http://www.voguejewelryzone.com authentic pandora beads

http://www.topsunglassesplazas.com Ray Ban Glasses For Sale

http://www.clothingsalemart.com Cheap Polo Ralph Lauren Store

http://www.clothingsalezone.com Polo Ralph Lauren outlet

http://www.clothingsaleshoppe.com Armani Suits Online

http://www.topclothesonsale.com Discount Polo Ralph Lauren

http://www.topclothescenter.com Clearance Ralph Lauren

http://www.topclothesstar.com Ralph Lauren Outlet Online

http://www.voguejewelryshow.com pandora bracelet sale

http://www.voguejewelrystar.com darling daisy bouquet pandora

http://www.voguejewelryonsale.com pandora charms cheap

Comment by maybee 3 weeks and 5 days ago

Please kindly take a look if any items you need now or like to collect.

All Brands shoes available! Like Adidas, Asics, Coverse, MBT, New Balance, Nike, Skechers, Timberland

Those shoes are 100% authentic. You can enjoy free shipping and no tax.

Welcome to check our store and contact us, we are here for your best service always.

http://www.adidasmessi16fg.us

http://www.nikeairmaxmotionlw.us

http://www.cheapairjordan4retroog.us

http://www.adidasultraboostolympic.us

http://www.suprableekerwomen.us

http://www.timberland6inchbootsshoes.us

http://www.nikezoomascentionmen.us

http://www.mbtkitabugtxshoes.us

http://www.airjordan2men.us

http://www.adidasdrose7shoes.us

http://www.mbtbaridiwomen.us

http://www.aikeairforce107high.us

http://www.nikeairhuarachemen.us

http://www.adidasclimacoolshoes.us

http://www.adidasneolabelchaussures.us

http://www.adidasnmdhumanrace.us

http://www.adidasoriginalszx500.us

http://www.adidasoriginalsstansmithwshoes.us

http://www.adidasoriginalspridepack.us

http://www.adidas11protf.us

http://www.adidasspringbladedriveshoes.us

http://www.adidastubularshoes.us

http://www.adidasyeezyboost550sale.us

http://www.adidasoriginalszx8000.us

http://www.nikeelasticoproiiiic.us

http://www.adidasmessi16ag.us

http://www.adidasoriginalsnmd.us

http://www.air-jordan-23.us

http://www.airjordan3men.us

http://www.nikeairmax-2017.us

http://www.adidasoriginalzxflux.us

http://www.adidasclimacoolboatshoe.us

http://www.nikeelasticoproiii-ic.us

http://www.adidassuperstar2shoes.us

http://www.nikeroshetwoflyknitshoes.us

http://www.stansmithadidasshoes.us

http://www.adidasultra-boost-shoes.us

http://www.mbtforagtxwomen.us

http://www.womenadidasneo.us

http://www.timberlandchukka-boots.us

http://www.adidasnmdshoesshop.us

http://www.nikemagistaobraic.us

http://www.mbtlamiwomen.us

http://www.adidasmessiic.us

http://www.timberland6inchbootsmen.us

http://www.nikeelasticofinaleiiistreettf.us

http://www.adidasnmdc1.us

http://www.nikeairmax2016-shoes.us

http://www.adidasstansmithprimeknit.us

http://www.adidasultraboost-uncaged.us

http://www.nikefreeflyknitnsw.us

http://www.kimondomen.us

http://www.kisumu2shoes.us

http://www.kisumushoes.us

http://www.flame-shoes.us

http://www.kimondogtxshoes.us

http://www.foragtxwomen.us

http://www.kifundomen.us

Comment by bertcarl1987 3 weeks and 1 day ago

Your point of view

You must be signed in to comment.