commandเป็นทุบตีbuiltinอย่างที่เราเห็น:
seth@host:~$ type command
command is a shell builtin
ดังนั้นเรารู้ว่าcommandมีให้โดยเปลือกของเราทุบตี เมื่อขุดลงไปman bashเราจะเห็นว่าการใช้คืออะไร:
(จากman bash):
command [-pVv] command [arg ...]
Run command with args suppressing the normal shell function
lookup. Only builtin commands or commands found in the PATH are
executed. If the -p option is given, the search for command is
performed using a default value for PATH that is guaranteed to
find all of the standard utilities. If either the -V or -v
option is supplied, a description of command is printed. The -v
option causes a single word indicating the command or file name
used to invoke command to be displayed; the -V option produces a
more verbose description. If the -V or -v option is supplied,
the exit status is 0 if command was found, and 1 if not. If
neither option is supplied and an error occurred or command
cannot be found, the exit status is 127. Otherwise, the exit
status of the command builtin is the exit status of command.
เป็นหลักคุณจะใช้commandเพื่อหลีกเลี่ยง "การค้นหาฟังก์ชั่นปกติ" ตัวอย่างเช่นสมมติว่าคุณมีฟังก์ชั่นใน.bashrc:
function say_hello() {
echo 'Hello!'
}
โดยปกติเมื่อคุณเรียกใช้say_helloในทุบตี terminal ของคุณจะพบว่าฟังก์ชั่นที่มีชื่อsay_helloในของคุณ.bashrc ก่อนที่จะพบว่าการพูด, say_helloแอพลิเคชันที่มีชื่อว่า โดยใช้:
command say_hello
ทำให้ทุบตีบายพาสค้นหาฟังก์ชั่นปกติและตรงไป builtins $PATHหรือของคุณ โปรดทราบว่าการค้นหาฟังก์ชั่นนี้ยังรวมถึงชื่อแทน การใช้commandจะข้ามทั้งฟังก์ชั่นและชื่อแทน
หาก-pตัวเลือกที่มีให้ทุบตีข้ามกำหนดเองของคุณ$PATHและใช้ค่าเริ่มต้นของตัวเอง
-vหรือ-Vธงทุบตีพิมพ์คำอธิบาย (สั้น-v, ยาว-V) ของคำสั่ง
หมายเหตุ: ดังที่ souravc ชี้ให้เห็นในความคิดเห็นวิธีการที่ง่ายขึ้นสำหรับการค้นหาข้อมูลเกี่ยวกับเชลล์บิวด์อินสามารถพบได้ที่นี่: จะทำให้ `คนทำงานได้อย่างไรสำหรับคำสั่งและคำหลักเชลล์บิวด์อิน?