How would this command be interpreted?
A nice alternative to which
is type
. They are similar, in that they both indicate how an argument keyword would be interpreted if used as a command name, but the output is different:
$ which ruby
/Users/jwworth/.rvm/rubies/ruby-2.1.0/bin/ruby
$ type ruby
ruby is /Users/jwworth/.rvm/rubies/ruby-2.1.0/bin/ruby
I prefer the type
syntax, especially with multiple arguments:
$ type ruby rails bundler
ruby is /Users/jwworth/.rvm/rubies/ruby-2.1.0/bin/ruby
rails is /Users/jwworth/.rvm/gems/ruby-2.1.0/bin/rails
bundler is /Users/jwworth/.rvm/gems/ruby-2.1.0/bin/bundler
Type includes a handy -t
flag, which tells you what type of thing the result is:
$ type -t type
builtin
$ type -t ruby
file
See help type
(in Bash) for more information.