Verify exit status
We can verify the exit statement of the true command but this command has to be used along with another command. For this purpose, a special shell variable (?) is used to store the status of the true command. This mechanism is illustrated in the below script.
Example:
#!/bin/sh
# Evaluates true then print the statement
true; echo “Status of the previous command is $?.”
Output:
Shell Scripting – True Command
A shell provides an interface with the help of which users can interact with the system easily. To directly interact with a shell, we use an operating system. On a Unix-based operating system, every time we write a command using a terminal, we interact with the system. To interpret or analyze Unix commands, we use a shell. The main job of a shell is to take commands from the user and convert them into the kernel’s understandable form. To summarize this, we can see it as a medium between a user and the kernel system of an OS. The kernel is a computer program that is considered the main part of a computer’s operating system.
This article focuses upon the shell scripting- True command.