Go The Linux type command

Source: Internet
Author: User
Tags aliases builtin

Transferred from: http://codingstandards.iteye.com/blog/831504

Description of Use

The type command is used to display the types of the specified command. The type of a command can be one of the following

    • Alias aliases
    • Keyword keyword, shell reserved word
    • function functions, Shell functions
    • Builtin built-in command, Shell built-in command
    • file files, disk files, external commands
    • Unfound didn't find it.

It's a self-reflection mechanism for Linux systems, and knowing the type, we can get help targeted. For example, the built-in command can use the help command to get assistance, and the external command uses man or info to get help.

Common parameters

The basic way to use the Type command is to follow the command name directly.

Type-a can display all possible types, such as the PWD is a shell built-in command, or it can be an external command.

Type-p only returns information for external commands, equivalent to the which command.

Type-f only returns information about the Shell function.

Type-t only returns information of the specified type.

Use the example example of what type of command you are

[Email protected] ~]#TYPE-A type
Type is a shell builtin
[Email protected] ~]#Help type
Type:type [-AFPTP] name [name ...]
For each NAME, indicate how it would be interpreted if used as a
Command name.

If the-t option is used, ' type ' outputs a single word which is one of
' Alias ', ' keyword ', ' function ', ' builtin ', ' file ' or ', if NAME is an '
Alias, shell reserved word, shell function, shell builtin, disk file,
or Unfound, respectively.

IF the-p flag is used, ' type ' either returns the name of the disk
file that would is executed, or nothing if the ' type-t NAME ' would not
Return ' file '.

IF the-a flag is used, ' type ' displays all of the places that contain
An executable named ' file '. This includes aliases, Builtins, and
Functions, if and only if THE-P flag are not also used.

The-f flag suppresses shell function lookup.

The-p flag forces a PATH search for each NAME, even if it's an alias,
Builtin, or function, and returns the name of the disk file that would
Be executed.
Typeset:typeset [-affirtx] [-p] name[=value] ...
Obsolete. See ' Declare '.
[Email protected] ~]#

Example two types of common commands

[Email protected] ~]#Type-a CD
CD is a shell builtin
[Email protected] ~]#type-a pwd
PWD is a shell builtin
PWD is/bin/pwd
[Email protected] ~]#Type-a time
Time is a shell keyword
Time Is/usr/bin/time
[Email protected] ~]#Type-a Date
Date Is/bin/date
[Email protected] ~]#Type-a which
Which is aliased to ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
Which Is/usr/bin/which
[Email protected] ~]#Type-a Whereis
Whereis Is/usr/bin/whereis
[Email protected] ~]#Type-a Whatis
Whatis Is/usr/bin/whatis
[Email protected] ~]#type-a function
function is a shell keyword
[Email protected] ~]#Type-a ls
LS is aliased to ' LS--color=tty '
LS Is/bin/ls
[Email protected] ~]#TYPE-A LL
ll is aliased to ' ls-l--color=tty '
[Email protected] ~]#Type-a Echo
Echo is a shell builtin
Echo Is/bin/echo
[Email protected] ~]#Type-a Bulitin 
-bash:type:bulitin:not found
[[email protected] ~]# type-a builtin 
Builtin is a shell Builtin
[[email protected] ~]# type-a keyword 
-bash:type:keyword:not found
[[email protected] ~]# type-a command 
command is a shell builtin
[[email protected] ~]# type-a alias 
alias is a shell builtin
[[email protected] ~]# type-a grep 
grep is/bin/grep
[[ Email protected] ~]#

[]linux Type command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.