1

I want to check if a command is builtin or a separate program. In sh and bash I use:

$ type <command>

What is the equivalent in csh?

3

csh has "which" (which cannot detect sh aliases)

In my environment using tcsh

~ (101) alias
cd      cd !* ; ls
q       exit
v       cursor; xhost + ;resize -s 40 80; unsetenv TERMCAP; screen
xl      xlock -nolock -random
y       Xearth; run xclock -geometry +1100+0; run nice xload -geometry +950+0 -update 3
~ (102) which y
y:       aliased to Xearth; run xclock -geometry +1100+0; run nice xload -geometry +950+0 -update 3
~ (103) type which
type: Command not found.
~ (104) which which
which: shell built-in command.
~ (105) which ls
/bin/ls
~ (106) 
  • In the version csh on my system, type which shows that which is /usr/bin/which and not a builtin, so csh does in fact not have it. It's a system binary. So YMMV on this. – DopeGhoti Aug 12 '16 at 22:46
  • If you're using something with Linux or BSDs (including OSX), odds are that you're using tcsh. Solaris uses "csh" from the early 1980s, and behaves as you indicate. – Thomas Dickey Aug 12 '16 at 22:49
  • Actually, the /usr/bin/type on xyr system is a shell script that uses the Almquist shell as its interpreter. Xe is thereby running the Almquist shell's builtin type command and seeing what is built into, and external to, the Almquist shell, rather than the TENEX C shell. This is part of what's so tricky about the whole which/where/whence/whereis/type/command -v mess. – JdeBP Aug 13 '16 at 8:38
2

Simply trying this shows:

$ csh
% type type
type is a shell builtin

So.. yes, you can?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.