Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the type command in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what is the use of the type command in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of type command in Linux" this article.

Linux common commands type commands are mainly used to display information about the commands to be found, to control the scope and behavior of the search, and to display the types of commands that have the highest priority.

Type displays the type of the specified command.

Summary type [- afptP] name [name.] Option-a: find and display all executable paths containing name in the environment variable PATH; when the'- p 'option is not given at the same time, if there is name in aliases, keywords, functions, and built-in information, it will be displayed as well. -f: excludes lookups for shell functions. -p: if name does not return file', when executing 'type-t name', then nothing will be returned; otherwise, the executable path will be found and returned in the environment variable PATH. -P: even if the name you are looking for is one of the aliases, built-ins, and functions, it still looks for and returns the executable path in the environment variable PATH. -t: returns a word (alias, keyword, function, built-in, file) based on the type of name, otherwise null. Parameter name: the command to find, which can be more than one.

The return value returns success when the specified command can be found, and fails if it is not found.

The next example to be used in the example assumes that the'~ / .bashrc 'file defines the following: alias ls='ls-- color=auto' mybash () {vim ~ / .bashrc;} and enable is not used in the execution environment to disable the built-in command. Type-a mybash # output mybash is a function mybash () {vim ~ / .bashrc} type-a-f mybash # output (error because the function is excluded) bash: type: mybash: not found type-a-p mybash # output is empty (because the function is excluded So nothing is returned) type-a ls # output ls is aliased to `ls-- color=suto' ls is / usr/bin/ls ls is / bin/ls type-a-p ls # output / usr/bin/ls / bin/ls #'- f 'does not affect the range of'-P','- f'is not recommended and used in'- p'. # Note: printf is both a built-in command and an executable file (GNU coreutils), which is treated as a built-in priority. Type-p printf # output is empty type-P printf # output / usr/bin/printf / bin/printf # if there are multiple types, then the type with the highest priority is output. Type-t ls # output alias type-t for # output (bash keyword) keyword type-t mybash # output function type-t-f mybash # output null value type-t printf # output (bash built-in priority) builtin type-t chmod # output file Note this command is bash built-in command, for related help, please see the help command.

For command priority issues, please see the builtin command.

The above is all the content of the article "what is the use of type commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report