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

Delete all empty lines from a file with vim

Terminal - Delete all empty lines from a file with vim
:g!/\S/d
2009-03-02 23:58:45
User: leonza99
16
Delete all empty lines from a file with vim

This command delete all the empty lines (include the lines with space) from a file.

g = global command

\S = non-whitespace character; !\S the opposite

d = delete a range

Alternatives

There are 2 alternatives - vote for the best!

Terminal - Alternatives
:g/^$/d
:v/./d
2013-09-08 23:22:02
User: MarxBro
Tags: vim
5

If you need to delete lines that may contain space characters (such as tabs or spaces) as well as empty ones, try:

:v/\S/d

Just an alternative.

[email protected]@q
2013-08-16 20:37:44
User: evilsoup
Tags: vim
-2

Here's the other way of doing it in vim: setting a recursive macro. 'gg' brings you to the top of the buffer, 'qqq' clears the 'q' macro, 'qq' starts recording a macro called 'q', '/^$' moves the cursor to the next empty line, 'dd' deletes the line that the cursor is on, [email protected]' calls the 'q' macro (currently empty because of 'qqq'), and 'q' stops recording the macro. [email protected]' calls the macro.

It will run until it cannot find another blank line, at which point it will throw up an error and cease.

While this is longer than the regex, you can use it without having to move your thoughts from 'vim-mode' to 'regex-mode'.

Know a better way?

If you can do better, submit your command here.

What others think

':g/^\s*$/d' is two characters(three, if you count ) longer, but it doesn't highlight everything if you have 'hlsearch' on. Two extra characters saves you from possibly having to type ':nohl'

Comment by leper421 409 weeks and 5 days ago

The above comment should say "(three if you count 'shift')"

Comment by leper421 409 weeks and 5 days ago

It did actually understand why Store offers attained this kind of exclusive name as well as precisely why he's going to regularly be one of many top Us builders involving perpetuity.If you don't intend to prepare income or even receive bags which aren't in time of year, endeavor buying replicates in the original. A great number of are extremely made along with manufacturers target the inside of and exterior of your original documents prior to these people duplicate every one. While they aren't the actual offer you, you could consider these individuals while knockoff which can be cost effective and search great.The techie know-how in the Swiss watch-making custom is a assurance regarding high quality as well as detail. The top good quality of any Versace watch is guaranteed by the Swiss Made' noting. Each chronograph is run through exacting requires and all solutions for you to intensive tests. Versace examines offer you specific patterns if you wish to jump out.In Feb . this current year, MK uncovered Finally quarter gross income of economic year Next year: Over-all revenue became 60 to 70.4 percent for you to Dollar 636.8-10 number of, $ 373.Half-dozen thousand to the same duration this past year. Store online profits widened 66.8 percent in order to $ 332.Six 500, a boost regarding 41.4 % year-on-year look gross sales, from suppliers web product sales greater 77.Four percent for you to Dollar 274.3 thousand; certificate revenue increased Fifty-two.1 percent to Money 30.Seven 1,000. Markup increased through 72.8 % year-on-year to Money 383.Your five thousand, disgusting structure associated with 62.2 percent.Kors' add-ons, in particular his or her handbags, have truly turned out to be the significant fashion amongst women who get actually consistently leaned toward programmer bags like Train, Dooney in addition to Lauren, overtaking these in acceptance.Review actually reduced charges vehicle insurance coverage throughout South Carolina can be currently an easy as well as simple really make a difference many thanks to make application for the internet alongside i actually have the ability to profusion involving internet sites that allow someone to assessment auto insurance coverage premiums by a lot of one of a kind coverage organizations. All the same, just typing in for you to information with in a single compare internet website without an actual system with regard to locking down the smallest possible assortment is as an alternative unwanted.Now, what you need is actually capture this contemporary entire world, and judge the fashion http://www.hermesbeltsbirkinkellybag.co.uk/ bags. Science and technology moreover engage in an important role in the socialist design. Along with consequently vital, you might need that Bags to reveal your current contemporary manner. And you'll neurological for being i am sorry pertaining to to obtain it, due to the fact is actually lack of feeling time for the structure occasion. Do not hold off anymore.Attention to help details, passion and also determination are usually Versace's most distinctive capabilities. The timepiece collections espouse your label's methods, the actual preciseness connected with Switzerland watch-making along with the form of Italian high quality necklaces. That they blend Switzerland precision executive using Italian language style and design. Regard pertaining to personalized assimilate that has a steady look for perfection along with Versace is distinguishable because of its enthusiastic research with the classification and using of emblems and also several components in addition to stones.

Comment by stephanieg915 2 days ago

www.canadagoosefemmeh

Comment by sguerra376 20 hours ago

Your point of view

You must be signed in to comment.