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

Alternative for basename using grep to extract file name

Terminal - Alternative for basename using grep to extract file name
fileName(){ echo ${1##*/}; }
2011-08-19 22:32:16
User: putnamhill
Functions: echo
1
Alternative for basename using grep to extract file name

Here's a bash version.

Alternatives

There are 5 alternatives - vote for the best!

Terminal - Alternatives
fileName() { echo "$1" | grep -o "[^/]*$"; }
2011-08-19 18:16:22
User: totti
Functions: echo grep
Tags: grep basename
-1
fileName /path/to/file.ext

quivalent to

basename /path/to/file.ext

Know a better way?

If you can do better, submit your command here.

What others think

Useless function wrapping.

Just use "${1##*/}" wherever you need to in your script, you make nothing shorter or faster.

Comment by RanyAlbeg 282 weeks and 3 days ago

Calculate wrist watches most appropriate way of accessorising your thing through an eye-catching part. The brand name is definitely ultra interesting yet incorporates a sensible price tag, allowing somewhat newer customers to benefit from the Imagine layout. With lots of variations easily obtainable between basic to be able to classy as well as issues among, Appraisal perceives include a tip of bling causing them to be search splendidly desirable, entertaining and sophisticated.The Finances, relogios, label initiated with girls don. Any collection with aspects has been offered throughout Late 2001. Together with Guess this is stuck to using a number of wrist watches throughout 2008. Remembering 25 very long times from the layout small enterprise, the MK draw can be efficiently produced & pertained to help because of it happens to be high quality from economical rate.All Versace products modify N't Promises, the actual Kimberly Process and the Assure Process. Versace acquisitions diamonds completely from genuine sources, simply because which it will depend on the value of strength.The National socialite Rome Hilton can be a celebutante, heiress, model, mass media individuality, vocalist and celebrity and it's do not ever out from the headers for my child ever-evolving feuds with some other other Showmanship party class famous people, ever-changing style of pets along with males, numerous string connected with complications above all clothing, shoes, hairdo in addition to her over the top diamonds jewellery. Paris, france Hilton pieces brand-new criteria for fashion in addition to accessories as well as socialites every time the lady awakens early in the morning. You could possibly chose to such as the woman's or perhaps detest the woman, yet simply do not have the substitute for ignore London Hilton. She's regularly from the spot http://www.hermesbeltsbirkinkellybag.co.uk/ light wherever she should go.The sensibly youthful creator Alexander Wang has a effectiveness historical past for laid-back & considerably macho collections. Therefore it appears seeing that virtually no influence that she is a huge particular person to view by a great deal of of the style publications adhering to this Athletics Luxe style.The greatest style trend mark, Paris Hilton's layout is mostly remarkable, although there have actually been numerous occasions in which she has already been busted by the vogue police regarding doing fashion tendency man-made marche of the greatest buy. It is commonly because the attractive heiress takes your ex vogue somewhat seriously along with loves to always be huge eye-catching in addition to strong in their own selection of outfits, which usually seeing that many of us know, can certainly fail.Aside by the woman's significantly discussed bags, developer shoes along with over-sized sunglasses that he continuously wears, the favored, or rather the key addition in the Basic Life' celebrity, is the woman's Qi. Paris, france provides allegedly Four Chihuahuas named Harajuku, Tokyo, japan, Bambi, and also Tinkerbell. Jane is furthermore recognised along with endorsing the actual "toy pet" craze regarding transporting a tiny family pet inside your extra-large bag, which usually she has carried out with both Tinkerbell and also various other Chihuahua, Bambi. This author of Confessions associated with an Heiress: A new Tongue-in-Chic Quick look Driving the Healthy posture, Venice sports her viewpoint on her behalf masturbator sleeves. The lady ended up being of late decided inside a white t shirt having a assertion, I adore shoes and boots, bags along with boys'.Right soon after transferring to Ny from 16 to receive up his / her spot on Parsons, the popular organization connected with design and style, he / she still left as part of his Next year. A variety that did not have any style of not well has an effect on upon his or her prolonged manage vocation since the First selection put into practice inside June 2006. She has missing coming from durability to longevity beneficial many honors.

Comment by stephanieg915 1 day ago

In your technique of finding out which often corporate gifts you need to be offering, you may wonder whether you must move the conventional path. Through history, consequently you'll probably still entertain the thought that folks may want to have the typical promotional items, for example pens and also bags. This might be something may lead that you the issue in particular because they items are less expensive as compared to the more professional plus more interesting electronics for example Universal serial bus memory space is. Even so, you will be amazed to find out of which dog pens and bags nonetheless preserve their own appeal to individuals.Promotional pencils are definitely things which are usually in the marketplace for many, many years already. In fact, it's widely thought if your thought of freely giving items for advertising was created, companies presently had pencils within their brains as the best choices. This could be related to the fact that these kinds of merchandise is cost effective and cannot possibly be weighty about the budget of those that are preparing to deliver these types of totally free. In addition to that, pencils are very useful. They are familiar with write just about everything, this is why people would never hesitate to take these types of.Promotional bags were also extremely popular selections. For people firms that are very significantly enthusiastic about so that his or her models are located by simply lots more people rather than just people that acquired the company products, bags really are the top alternatives. When bags are moved close to, the brand names as well as graphics usually are thus available and observed through the best way to. As a result, the particular advertising and marketing factor is actually even more improved, with increased customers being achieved because of the subliminal concept of the brand logo and name. http://www.hermesbeltsbirkinkellybag.co.uk/ This can be the primary reason the reason why there are far more businesses that nevertheless use these for his or her special offers instead of trying the new. It is incredibly crystal clear that offering promotional pens and bags includes a great advantage. Although this can look like a smaller amount exciting when compared with additional goods that tend to be more technologically sophisticated, folks could not control by themselves by basically getting these kinds of in the event that they're basically granted at no cost. As these are less costly, sure it's smart to nonetheless utilize these as your tackle; things that would actually allow you to save on your financial budget yet still supply you with greatest results. As a result, your organization would really make the most from the.With advantages receiving by means of promotional bags, there is truly no satisfied answer why you must avoid becoming an option. Nevertheless, although these things usually are affordable along with popular, don't ever ignore the extreme will need these are of high quality. This means that you must learn no matter whether people who you might be handing out are true top in the market. Simply because they are inexpensive does not meant there would become no requirement to make certain quality. People could not arranged this facet away even when this stuff are free.

Comment by stephanieg915 1 day ago

Your point of view

You must be signed in to comment.