A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-bash/zsh: command command not not found # Windows (WSL2) sudo apt-get update sudo apt-get install bash # Debian apt-get install bash # Ubuntu apt-get install bash # Alpine apk add bash # Arch Linux pacman -S bash # Kali Linux apt-get install bash # CentOS yum install bash # Fedora dnf install bash # OS X brew install bash # Raspbian apt-get install bash # Dockerfile dockerfile.run/command # Docker docker run cmd.cat/command command
command命令 调用指定的指令并执行,命令执行时不查询 Shell 函数。command 命令只能够执行 Shell 内部的命令。
[root@TestMaster ~] # type command command is a shell builtin
command [-p] [-v] [-V] command [arg ...]
Execute the specified command but ignore shell functions when searching for it. (This is useful when you have a shell function with the same name as a builtin com‐ mand.) -p search for command using a PATH that guarantees to find all the standard util‐ities. -V Do not execute the command but search for the command and print the resolution of the command search. This is the same as the type builtin. -v Do not execute the command but search for the command and print the absolute pathname of utilities, the name for builtins or the expansion of aliases.
指令:需要调用的指令及参数。
使用command命令调用执行echo Linux,输入如下命令:
command echo Linux #调用执行shell内部指令 #上面的命令执行后,将调用执行命令echo Linux,其执行结果如下: Linux
写一个 Shell 脚本,test.sh
中构建 ls 函数,大家就可以体会 command 命令的作用:
#!/bin/bash function ls() { echo "CommandNotFound,发音:坑否" } echo "--1--" ls echo "--2--" command ls echo "--3--" echo command ls echo "--4--" $(echo command ls) -------------- #给脚本增加执行权限,并 test.sh,对比结果
下面是执行结果:
[root@TestMaster /Data] # ./test.sh --1-- CommandNotFound,发音:坑否 --2-- Android apps del_kworderds.sh ffmpeg_compress.sh ffmpeg_travel_debug.sh logs SSP.proto test.sh tools webapps --3-- command ls --4-- Android apps del_kworderds.sh ffmpeg_compress.sh ffmpeg_travel_debug.sh logs SSP.proto test.sh tools webapps
command ls
command 显示可执行文件的路径或特定命令的别名定义:
command -v command_name