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

a tail function for automatic smart output

Terminal - a tail function for automatic smart output
tail() { thbin="/usr/bin/tail"; if [ "${1:0:1}" != "-" ]; then fc=$(($#==0?1:$#)); lpf="$((($LINES - 3 - 2 * $fc) / $fc))"; lpf="$(($lpf<1?2:$lpf))"; [ $fc -eq 1 ] && $thbin -n $lpf "$@" | /usr/bin/fold -w $COLUMNS | $thbin -n $lpf || $thbin -n $lpf...
2012-03-23 19:00:30
User: fpunktk
Functions: tail
-1
a tail function for automatic smart output
tail() { thbin="/usr/bin/tail"; if [ "${1:0:1}" != "-" ]; then fc=$(($#==0?1:$#)); lpf="$((($LINES - 3 - 2 * $fc) / $fc))"; lpf="$(($lpf<1?2:$lpf))"; [ $fc -eq 1 ] && $thbin -n $lpf "$@" | /usr/bin/fold -w $COLUMNS | $thbin -n $lpf || $thbin -n $lpf "$@"; else $thbin "$@"; fi; unset lpf fc thbin; }

This is a function that implements an improved version of tail. It tries to limit the number of lines so that the screen is filled completely. It works with pipes, single and multiple files. If you add different options to tail, they will overwrite the settings from the function.

It doesn't work very well when too many files (with wrapped lines) are specified.

Its optimised for my three-line prompt.

It also works for head. Just s/tail/head/g

Don't set 'thbin="tail"', this might lead to a forkbomb.

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
alias tail='tail -n $((${LINES:-`tput lines 2>/dev/null||echo -n 80`} - 7))'
2012-03-22 02:44:11
User: AskApache
Functions: alias echo
2

Run the alias command, then issue

ps aux | tail

and resize your terminal window (putty/console/hyperterm/xterm/etc) then issue the same command and you'll understand.

${LINES:-`tput lines 2>/dev/null||echo -n 12`}

Insructs the shell that if LINES is not set or null to use the output from `tput lines` ( ncurses based terminal access ) to get the number of lines in your terminal. But furthermore, in case that doesn't work either, it will default to using the default of 80.

The default for TAIL is to output the last 10 lines, this alias changes the default to output the last x lines instead, where x is the number of lines currently displayed on your terminal - 7. The -7 is there so that the top line displayed is the command you ran that used TAIL, ie the prompt.

Depending on whether your PS1 and/or PROMPT_COMMAND output more than 1 line (mine is 3) you will want to increase from -2. So with my prompt being the following, I need -7, or - 5 if I only want to display the commandline at the top. ( http://www.askapache.com/linux/bash-power-prompt.html )

275MB/748MB

[7995:7993 - 0:186] 06:26:49 Thu Apr 08 [[email protected]:/dev/pts/0 +1] ~

In most shells the LINES variable is created automatically at login and updated when the terminal is resized (28 linux, 23/20 others for SIGWINCH) to contain the number of vertical lines that can fit in your terminal window. Because the alias doesn't hard-code the current LINES but relys on the $LINES variable, this is a dynamic alias that will always work on a tty device.

Know a better way?

If you can do better, submit your command here.

What others think

Within the You actually.Ohydrates., florida sales tax is usually a bunch additional tough. It does not appear until finally you will be waiting on this checkout only when it's simply just improved towards the acquire cost.You might look at web with circumstances you happen to be desperate to know further regarding Wallet Outlet Bags. You'll surely stumbled upon a collection of web page which in turn discover Handbags Electric powered electrical socket. Apart from the specifics, you could have a shape in the images too. You could potentially verify all the photos, designs, shades in addition to dimensions on the bags.A authentic female will need significant amounts of precious fragrance bottles * many different cases, various time, time and also spirits. Effortlessly, a superb scent is expensive. Nevertheless, fragrance market incorporates a bunch of reproductions right now, and often the more expensive price ( space ) is not a promise of top quality. That's why you may want to select your fragrance extremely totally and buy it just inside excellent retailers.Do guess what happens would be the among the"parfum", the particular "eau de parfum" along with the "eau de toilette"? For starters your aroma will cost you more. It has 30-40 percentage of the fragrant natural oils and thus contain the most reliable along with targeted fragrance, as well as on the greater attentiveness it is enough to work with just a couple droplets. The particular stench remains on your skin regarding 6-9 a long time. It is far better to use it night time aroma.Android appears to have been production reliable and classy wrist watches for many years. Because there can be fellas associated with variance and also inclination who will not really select everything nevertheless the best -- offering the wrist watches.Distinct however flashy, this specific variable observe can be geared up that has a silver tone or perhaps dark ionic-plated spherical metal circumstances using a push/pull overhead. Glowing hours as well as minute palms, catalog guns in addition to numerals comparison effectively with all the spherical burgundy, glowing blue as well as dark-colored contact. A good "open-heart" eye-port on the switch gives you a review of the particular TY2807 Intelligent action along with Twenty-one gem stones.Estimate ended up being really most likely the brand that basically built the top wardrobe addition object : the at any time devoted skinny jeans, since known as these are today. If the Marciano friends presented http://www.hermesbeltsbirkinkellybag.co.uk/ his or her line of blue jeans, the idea of donning skinny jeans unexpectedly was additional attractive and consequently ended up being a massive trend containing caught. Ahead of Supposition introduced these kinds of denims, denims was always considereded seeing that easy traditional do the job clothes instead of regarded as trendy or even hot. In the event the Suppose trousers strike the actual cabinets plus the personalities were being rarely viewed with no fixed, this is anything planning to remodel.: Mystical Aroma Hills is usually a top online fragrance/perfume outlet, having a huge on the net fragrance merchandise option. Most of us pleasure each of our faces of the ability to provide you with together with perfect perfumes, products, gift idea choices, women perfumes, adult men perfumes as well as applying for the most beneficial discounts available for sale objects for you personally plus your relatived. . Our own things improvements daily therefore please take a look at rear commonly for your newest selection.

Comment by stephanieg915 1 day ago

Anybody will certainly pick one assortment of fantastic type of Internet store that you just or maybe probably may matter a selection inside through too, which feature hobos, pockets, handbags, potential buyers, in addition to flap creator bags. It really is considerable to work with you require a bit of moment with admit which in turn particular type is nearly definitely to function a lot of absolutely greatest for you personally as a matter of actuality. Regarding affair when you've got the modern trend to undertake a total car car dealership to hold flexible anyone Would certainly potentially receiving a fantastic payment a lot more dependable lower deciding on a good valuable hobo bag along with satchel because where there are possibly time for be added in housing.Michael Kors features the most superior in addition to impressive night time developer clutch i465 black variety which will absolutely impress any sort of ingest ensemble. This females designer night clutch system selection attributes stunning colours, outstanding patterns with personal essentials. Here are some of the most up-to-date custom handbags from the night time clutch i465 collection.If you want artist bags with regard to by all on your own or for re-sale and do not advocate to cover costly costs, there are a amazing deal of selections. A fantastic deal of creator bags can be offered http://www.hermesbeltsbirkinkellybag.co.uk/ in a selection connected with processes and they also don't attribute terrifying a new months income to obtain these people. Abide by the actual hints shown the following to experience how you are able to most likely purchase cost-effective Handbags bags within an option of business.Focus on data, interest rate as well as commitment tend to be Versace's virtually all different capabilities. This watch collections uphold the manufacturer name's lure, the truth of Europe watch-making along with the enlargement connected with German outstanding top quality diamond jewelry. These people assimilate Physical exercise trustworthiness style together with Italian language type. Consider pertaining to personalized add which has a typical search for top quality along with Versace is unique due to its enthusiastic exploration with the relevance as well as utilization of signs and also numerous components as well as stones.Michael Kors HandbagsWhatever this inspiration to the returning with this vintage appearance, commemorate likely to subscribe together with past Pandora Diamond jewelry collections in succeeding as utilized because of the quite a few dedicated hobbyists of the brand which often will continue to virally spreading in to considering that their 3 years ago UK launching.MK is a high-end brand which has in honest truth produced it is excellent ethics. Raises the bar in including the CFDA Girl's Developer of this year within 2004, your CFDA Guys's Custom made of the year throughout 2002 as well as the CFDA Life Achievement Respect really have got in fact shown the planet the reason the particular MK's series can be an stress and anxiety being considered. alone takes a authority purpose within the file format of the goods. Maybe this is why the trademark name offers actually continuouslied develop and also take in that considerable customers. Their enjoy variety features really stored a sensation of top good quality and design that could surely position supporters for too long times beforehand.Which, as being the Private coach planet's major market place within To the north The actual incorporated state profits increased by simply 1 % in order to 1 dollar.2007 thousand, even though Coach with every three months gross sales regarding A buck.A few zillion, is actually MK 2 times, nevertheless its You.Azines. same-store product sales minimized 2 %, though Erina This Kors throughout similar electric outlet revenue in N . This usa state increased by simply Forty one percent.Peter Burrowes give you a large assortment of design wrist watches and jewelry by top design brand like watches, Tissot recognizes, Forecasts experiences, DKNY wristwatches along with treasured jewelry, Emporio Armani checks out and jewelry, Calvin Klein CK likes and jewellery, Chronotech checks out, D&G perceives, Diesel-powered designer watches and jewellery, Gc landscapes, Hamilton experiences, Limited considers, Bags loves, Mondaine ordeals, Experts examines, Switching watches, TechnoMarine checks out, Tissot checks out, Wenger views, wristwatches along with Burberry wrist watches.

Comment by stephanieg915 18 hours ago

Your point of view

You must be signed in to comment.