Determine if a command is in your $PATH using POSIX

command -v bash
it is generally advised to avoid using which(1) whenever possible. which(1) is usually a csh(1) script, or sometimes a compiled binary. It's output is highly variable from operating system to operating system, so platform independent scripts could become quite complicated with the logic. On HP-UX 10.20, for example, it prints "no bash in /path /path /path ..."; on OpenBSD 4.1, it prints "bash: Command not found."; on Debian (3.1 through 5.0 at least) and SuSE, it prints nothing at all; on Red Hat 5.2, it prints "which: no bash in (/path:/path:...)"; on Red Hat 6.2, it writes the same message, but on standard error instead of standard output; and on Gentoo, it writes something on stderr. And given all these differences, it's still variable based on your shell. This is why POSIX is king. See http://mywiki.wooledge.org/BashFAQ/081 for more ways on avoiding which(1).
Sample Output
/bin/bash

4
By: atoponce
2011-09-26 10:17:41

What Others Think

there is still a problem with bash! if there is an alias with the same name it will give you the alias: command -v ls alias ls='ls --color=auto'
zwettler · 651 weeks ago
@zwettler try this instead command -v /bin/ls also try help command for all the options on `command`
unixmonkey365 · 650 weeks and 4 days ago
@unixmonkey24656 true, that works. but you have to know the whole path of the file and you don't get all instances of it in your $PATH. if you just want to check this particular instance its probably the best.
zwettler · 650 weeks and 4 days ago
The question is why is it so "highly variable", I'd hazzard that its because bash doesn't have it as a builtin. In the above HP-UX and OpenBSD outputs the scripts are obviously calling bash, and *very* oddly this seems the case for the two versions of Redhat you cite. Gentoo's sys-apps/which is part of @system, and the carlo17 binary, is there because the default shell, bash, doesn't provide it. Most of this can be attributed to the expectation that bash is present and as it doesn't provide 'which' as a builtin and so needs a 'bash' script or external binary. A Secondary question is why if POSIX shells support 'command' did 'which' come into such prevelant use ... pdksh, zsh, mksh, have both 'command' and 'which'/'whence' as builtins for that same purpose, so some external command isn't required, but the same case can't be made for bash. So, really, this isn't a case of "POSIX is king" but an issue directly attributable to bash being poorly equiped, and all the kludges whipped up to work arround the issue.
khayyam · 571 weeks and 2 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
rahimhh21 · 81 weeks and 3 days ago
Saxenda Kopen Oxycodon 40 mg kopen Champix kopen Oxycodon teva kopen Tramadol 100 mg Stilnox 10mg kopen Strattera kopen Oxycodon kopen Diazepam 10 mg kopen Morfine injecteren Tylenol kopen Tramadol dosering Xanax 2mg kopen Lyrica 300mg Kopen Azithromycin 250 Kopen Oxycodon hcl Kopen Sustanon Kopen Ritalin Kopen Tramadol 50 mg Kopen Nolvadex Kopen Morfine 60 mg Kopen Pijnstillers oxycodon Oxycodone 20 mg Kopen Amoxicilline Kopen Benzedrine Kopen Insuline Kopen Suboxone Kopen Percocet Kopen Amfetamine Kopen Quaalude Kopen Fentanyl pleister Kopen Oxycontin kopen Oxycontin 40 mg Doxycycline 50 mg Alprazolam kopen Diclofenac kopen ketamine kopen Methamfetamine kopen Cocaine kopen Dexedrine kopen Oxazepam 50 mg Codeine kopen Flunitrazepam 2mg Mirtazapine kopen Midazolam kopen Nembutal kopen Temazepam 10 mg Oxycodon retardtabletten Fentanyl pleister Bromazepam 3 mg kopen Bromazepam kopen Doxycycline kopen Dormicum 15 mg Concerta kopen Kamagra 100mg kopen Baclofen kopen Temazepam 20 mg kopen Pijnstiller oxycodon Lasix-40mg kopen Lorazepam kopen Lorazepam 2.5 MG kopen Lyrica medicatie kopen Ketamine kopen Enanthate kopen Finasteride kopen Flurazepam kopen Concerta 36 mg kopen Concerta 54 mg kopen Adderall Nederland Imovane 7.5 mg kopen Clonazepam kopen Naproxen kopen Mdma capsules Zolpidem kopen Saxenda kopen Pijnstiller kopen Morfine Kopen Oxycontin 40 mg kopen Suboxon kopen MDMA Kopen Methylphenidate Kopen Naproxen Kopen Quaalude Kopen Morfine Injecteren Fentanyl Pleister Clonazepam Kopen Imovane Kopen Adderall Nederland Concerta 54 mg Kopen Concerta 36 mg Kopen Flurazepam Kopen Finasteride Kopen Amfetamine Kopen Amoxicilline Kopen Cocaine Kopen Diazepam Kopen Enanthate Kopen Ketamine Kopen Lyrica Medicatie Ketamine 10 gram Lorazepam 25 mg Lorazepam Kopen Lasix 40mg Kopen Percocet kopen Pijnstiller Oxycodon Pijnstillers Oxycodon Temazepam 20 mg Saxenda Kopen Champix Kopen Baclofen Kopen Doxycycline 50 mg Kamagra Kopen Oxycodon hcl Azithromycin Kopen Adderall Pillen Kopen Dexedrine Kopen Methamfetamine Kopen Oxycontin Kopen Concerta Kopen Dormicum 15 mg Diclofenac Kopen Doxycycline Kopen Bromazepam Kopen Bromazepam 3 mg kopen Fentanyl Pleister Kopen Oxycodon Retardtabletten Temazepam 10 mg Kopen Strattera 40 mg Kopen Lyrica 300mg Kopen Nembutal Kopen Midazolam Kopen Mirtazapine Kopen Insuline 10ml Kopen Flunitrazepam 2mg Benzedrine kopen Tylenol Kopen Ritalin Kopen Codeine 15mg Oxazepam Kopen Oxycodon Kopen oxycodone 20mg Kopen Xanax gele kopen Stilnox Kopen Alprazolam Kopen Zolpidem Kopen Nolvadex 10mg Kopen Oxycodon Slapen Sustanon Kopen Tramadol 200mg Tramadol 100mg Tramadol Paracetamol Kaufen Sie Oxycodon ohne Rezept Schmerzmittel kaufen Etizolam kaufen Lormetazepam kaufen Mirtazapin kaufen Oxazepam kaufen Oxazepam 50mg kaufen Pantoprazol kaufen Xanax 2mg kaufen Xanax 1 mg kaufen Temazepam kaufen Tramadol 50 mg kaufen Genotropin pen kaufen Flurazepam kaufen Finasterid kaufen Dormicum kaufen Diclofenac kaufen Concerta Tabletten kaufen Champix kaufen Bromazepam 6 mg kaufen Bromazepam 3 mg kaufen Baclofen kaufen Oxycodon Naloxon kaufen Nitrazepam 10 mg kaufen Clonazepam 2mg kaufen kaufen Adderall Ritalin 10mg kaufen Concerta 36 mg kaufen Concerta 54 mg kaufen Morphin kaufen Nitrazepam kaufen Oxycodon 5 mg kaufen Lorazepam kaufen Fentanyl Pflaster kaufen Temazepam kaufen Diazepam Rektal kaufen Ephedrin kaufen Lorazepam kaufen Oxycodon droge 15mg kaufen Tramadol 100 mg kaufen Doxycyclin kaufen Oxycodon Schmerzmittel kaufen Saxenda kaufen Oxycodon 40mg kaufen Diazepam kaufen Zolpidem kaufen Oxycodon 20 mg kaufen oxycodon 80 mg kaufen Oxycodon 10 mg kaufen Zopiclon kaufen Buy shipping containers in the USA and Canada online only with Queen Containers your most trusted and reliable shipping container supplier. We operate out of Texas and California. Buy Container Chassis, Shipping Container Accessories, Cold Containers, Blast freezers etc. Contact Queencontainers.com at support@queencontainers.com for more info https://queencontainers.com/ container chassis for sale 40 tilt bed trailer 40 ft reefer container blast reezer Buy freight farms 40 shipping container for sale Buy 40ft shipping container 40 shipping container shipping container sizes storage container with roll up door 45 HC shipping containers Buy drum pallets Buy wing pallet Buy new wood pallets Buy block pallet 20ft reefer container modified shipping containers 20 ft container 20ft HC shipping containers 40 ft shipping container for sale 10ft reefer container oxycodone Buy Acxion 30 mg Buy 20 mg Adderall Buy Alprazolam 1mg Buy Benzedrine pills Buy Codeine Phosphate Buy Concerta 18 mg Buy Concerta 27 mg Buy Concerta 54 mg Buy Dexedrine 10 mg Buy Diazepam 10 mg Buy Finasteride 5mg Buy Flunitrazepam 2mg Buy flurazepam 30 mg Buy generic adderall 30 mg Buy kamagra 100mg Buy ketamine 500mh Buy Lorazepam 1mg Buy Lorazepam 2 mg Buy lyrica 300 mg Buy generic lyrica Buy methylphenidate 20 mg Buy mirtazapine 30mg Buy mirtazapine 15 mg Buy mirtazapine 7.5 mg Buy morphine sulfate Buy naproxen 500 mg Buy oxazepam 15 mg Buy oxycodone 15mg Buy oxycodone 10mg Buy oxycodone 20mg Buy oxycodone 30mg Buy oxycodone 5mg Buy oxycodone hcl 60mg Buy oxycodone hydrochloride Buy oxycodone pill 80 mg Buy quaalude 300 mg Buy saxenda Buy strattera 40 mg Buy temazepam 10mg Buy temazepam 15 mg Buy temazepam 20 mg Buy temazepam 30 mg Buy testosterone enanthate Buy tramadol 50 mg Buy tramadol 100mg Buy voltaren 75 mg Buy voltaren pill Buy wegovy 2.4 mg Buy xanax 2mg Buy zolpidem 10 mg Buy fentanyl patch 100mcgh Buy transdermal fentanyl patch Buy lasix 40 mg Buy zolpidem 5mg Buy naproxen 250 mg Buy morphine sulfate 20mg/ml Bent u op zoek naar een containerdepot, dockingdiensten, containertransport, warehousing, zeecontainerreparaties etc. dan is A.S.H.C.CO hier om ervoor te zorgen dat u de beste containerdiensten krijgt in heel Europa. Neem contact op met Support@ashcco.com voor meer details https://ashcco.com/ 10 ft Container Blast Freezer 40 ft Reefer Container Reefer Container 40ft Shipping Container 40 ft Container Kopen Zeecontainer 40ft Zeecontainer 20ft Kopen Zeecontainer 20ft Pallet Kopen Euro Pallet Blok Pallet Pallets
alexander99 · 74 weeks and 2 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies baby pug puppies for sale pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
Perfecthomepugs · 72 weeks and 1 day ago
My comfort comes from a website called signnow.com/ask/how-to-sign-a-pdf-that-has-already-been-signed-by-someone-else. I actually had everything in my hands in record time. Highly recommended!
seoexpert · 35 weeks and 4 days ago
Dissatisafaction diffuses among customers when the company is not responding in its ideal manner. But there are companies like document-generation who form some page where they can interact wit
seoexpert · 35 weeks and 2 days ago
If it's not too much trouble share more like that. Immobilien Emsland
seoexpert · 34 weeks and 6 days ago
Perfect House Of Pugs acquired a passion for animals, and the Pug puppy in particular, at a young age since I grew up in a house with lots of dogs. It was a natural ability to know how to grow, nurture, and care for animals. I knew what the future held when I met my wife, who essentially had the same enthusiasm as I have. Being a breeder is more of a passion for me than a profession since I get to witness people's faces light up when they successfully adopt a pug puppy from our facility. It is not possible to find happiness in anything else. PLEASE VISIT OUR WEBSITE LINK BELLOW FOR MORE INFORMATION ABOUT PUG PUPPIES. PUG PUPPY ADOPTION Pug puppies for sale PUG PUPPIES FOR SALE NEAR ME PUG PUPPIES NEAR ME PUG PUPPIES FOR SALE UNDER 500 NEAR ME CUTE PUG PUPPIES BLACK PUG PUPPIES BLACK PUG PUPPIES FOR SALE PUG PUPPIES FOR ADOPTION BLACK PUG PUPPIES FOR SALE NEAR ME CHIHUAHUA PUG MIX PUPPIES TEACUP PUG PUPPIES HOW MUCH IS A PUG PUPPY BABY PUG PUPPIES PICTURES OF PUG PUPPIES PUG PUPPIES FOR SALE IN OHIO PUG PUPPIES FOR SALE IN PA PUG PUPPIES PRICE PUG MIX PUPPIES TEACUP PUG PUPPIES FOR SALE BABY PUG PUPPIES FOR SALE BEST FOOD FOR PUG PUPPY NEWBORN PUG PUPPIES PUG PUPPIES CRAIGSLIST PUG PUPPIES FOR SALE CRAIGSLIST WHITE PUG PUPPIES PUG PUPPIES FOR SALE IN MICHIGAN PUG PUPPIES FOR SALE UNDER 500 ADORABLE PUG PUPPIES BRINDLE PUG PUPPY HOW MUCH DOES A PUG PUPPY COST PITBULL PUG MIX PUPPIES PUGS FOR SALE NEAR ME PUG PUPPIES FOR SALE 200 PUG PUPPIES FOR SALE IN NJ PUG PUPPIES FOR SALE IN WISCONSIN PUG PUPPIES MICHIGAN PUG PUPPY COST MERLE PUG PUPPY FOR ADOPTION BEST PUG PUPPY FOOD ROYAL CANIN PUG PUPPY FOOD FAWN PUG PUPPY PUG PUPPIES FOR SALE FLORIDA PUG PUPPIES FOR SALE IN INDIANA PUG PUPPIES FOR SALE IN KY PUG PUPPIES FOR SALE IN NC PUG PUPPIES FOR SALE IN TEXAS PUG PUPPIES FOR SALE MN PUG DOG PUPPY AKC REGISTERED PUG PUPPIES FOR SALE PUG ALL BLACK CHEAP PUG PUPPIES FOR SALE NEAR ME PUGS PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN CALIFORNIA MINIATURE PUG PUPPIES FOR SALE NEAR ME MINIATURE PUG PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN NJ KNOWN FACTS ABOUT PUG PUPPIES ADOPT PUG PUPPIS RECUE A PUG PUPPY PERFECT HOUSE OF PUGS PUG PUPPIES INSTAGRAM PINTEREST QUORA Google Page USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA
pugpuppies95 · 34 weeks and 2 days ago
Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work!!! tradesviz avis
yoknutarza · 5 weeks and 2 days ago
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information... Instagram spam report
yoknutarza · 5 weeks and 1 day ago
Use https://www.signnow.com if you need to distribute a document—like a survey or questionnaire—to a large number of recipients. With the help of its capabilities, you may easily and quickly develop and submit signature forms using an eSignature process.
yoknutarza · 4 weeks and 5 days ago
I have discovered this website called https://www.airslate.com/product/electronic-signature. To be honest, the extraordinary performance of this platform continues to astonish me. Check it out for yourself!
yoknutarza · 4 weeks and 4 days ago
I just could not go away your site prior to suggesting that I really loved the usual info an individual supply in your visitors? Is gonna be again incessantly to check up on new posts. Website
robinjack · 3 weeks and 6 days ago
Magnificent goods from you, man. I have understand your stuff previous to and you are just extremely excellent. I really like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it sensible. I can not wait to read much more from you. This is actually a wonderful web site. sbobet
robinjack · 3 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands



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: