"which" and "type" (was: Ubuntu installation questions)
- From: Teemu Likonen <tlikonen@xxxxxx>
- Date: Sun, 16 Aug 2009 15:06:53 GMT
On 2009-08-16 07:34 (-0700), Nick K. wrote:
On Aug 15, 6:11 pm, Aragorn <arag...@xxxxxxxxxxxxxxxxxxx> wrote:
If you want to know where an executable is located (or which version of
the executable you would be invoking), then it is best to use /type,/
like so...
type latex
I have never seen a command called "type" but I suspect it must be an
internal command to the bash shell. The command "which" seems to do
the same thing and also has its own man page. What is the difference
between using one or the other?
Yes, "type" is a Bash builtin but the commands are not the same. "which"
locates a command in $PATH. It searches only for executable files in the
filesystem. Bash's "type" returns the type of command:
$ type printf
printf is a shell builtin
$ which printf
/usr/bin/printf
If I execute
$ printf "foo\n"
it will use the shell builtin. So, if you need to know "what will be
executed when I run command X without explicit path" then you need to
check "type X". "type" can also tell if command is a shell function:
$ type quote
quote is a function
quote ()
{
echo \'${1//\'/\'\\\'\'}\'
}
For more info: "help type" in Bash.
.
- References:
- Re: Ubuntu installation questions
- From: philo
- Re: Ubuntu installation questions
- From: John Goche
- Re: Ubuntu installation questions
- From: Aragorn
- Re: Ubuntu installation questions
- From: Nick K
- Re: Ubuntu installation questions
- Prev by Date: Re: Ubuntu installation questions
- Next by Date: Re: Sony VAIO and recovery drives
- Previous by thread: Re: Ubuntu installation questions
- Next by thread: WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
- Index(es):
Relevant Pages
|