Difference between revisions of "Type command"

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to navigation Jump to search
Line 19: Line 19:
 
| type -t date
 
| type -t date
 
| file
 
| file
| date command is a disk file ([[external command]])which can be verified by issued the '''which date''' command at a shell prompt:<br /><code>which date</code>
+
| date command is a disk file ([[external command]]), which can be verified by issued the '''which date''' command at a shell prompt:<br /><code>which date</code>
 
|-
 
|-
 
| type -t xrpm
 
| type -t xrpm

Revision as of 11:56, 12 September 2009

The type command is used to find out if command is builtin or external binary file. It also indicate how it would be interpreted if used as a command name.

Find Out Command Type

If the -t option is used, it will print a single word which is one of the following

  • alias (command is shell alias)
  • keyword (command is shell reserved word)
  • function (command is shell function)
  • builtin (command is shell builtin)
  • file (command is disk file)

Try the following examples:

Command Output Meaning
type -t ls alias ls command is alias which can be verified by typing the alias command itself at a shell prompt:
alias
type -t date file date command is a disk file (external command), which can be verified by issued the which date command at a shell prompt:
which date
type -t xrpm function xrpm is a user defined function.
type -t if keyword if is a shell reserved word, which is used for flow control.
type -t pwd builtin pwd is a shell builtin command.