Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4559266
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:45:53+00:00 2026-05-21T17:45:53+00:00

In csh, tcsh, bash, perl (etc) you can do tests on par with (not

  • 0

In csh, tcsh, bash, perl (etc) you can do tests on par with (not necessarily with the same syntax):

test -e PATH; # Does PATH exist
test -f PATH; # Is PATH a file
test -d PATH; # is PATh a directory
...

Does a similar construct exist for checking whether a binary is in your path? (and perhaps whether an alias, or even a built-in exist)

Obviously this can be done with something of the form:

#!/usr/bin/env bash
C=COMMAND;
test $(which $C) -o $(alias $C) && "$C exists"

or something similar in other shells/script languages.

The question isn’t whether it’s possible to test for the existence of a program, command, etc. The question is whether a built-in test exists or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:45:54+00:00Added an answer on May 21, 2026 at 5:45 pm

    Technically if you’re just looking for stuff in the current PATH then the only real solution is the first portion of your second code block:

    which $C
    

    which is the only one that really fits your actual requirement of in the current PATH as whereis will search outside the path:

    whereis … attempts to locate the desired program in a list of standard Linux places.

    from whereis(1)

    and alias of course has nothing to do with actual executables, but rather aliased commands within your shell environment

    So, really, you’ve got the right approach already, just be careful that you know that whereis may not be a helpful addition to that chain of tests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I check in bash and csh if commands are builtin? Is there
I need a good reference on unix shell special variables (csh, ksh and bash).
I have a C shell script that does something like this: #!/bin/csh gcc example.c
I am running tcsh/csh shell on my machine. lately i have realized my stderr
In CSH foreach loop or for loop, how can I add a loop iterator
I'm a long-time csh user trying (painfully) to convert to bash. My apologies if
I am calling a csh script that the first thing it does is starts
Which languages(think csh, ksh, bash, zsh..) compile into posix compatible sh? Please include a
#!/bin/csh -x exec bash source ~arovit/RTM_test/unit_RTM/fail.10/failure.001.sh exec csh <script continues...> is there any other
In CSH, is it possible to nest the test for an existance of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.