Bash - (Return|Exit) (Value|Status)

Bash Liste Des Attaques Ovh

Bash - (Return|Exit) (Value|Status)

About

The return status (also known as Exit Status of Exit Code) of a simple command is its exit status as provided by:

Management

Get

? is a special parameter that expands to the status of the most recently executed foreground pipeline.

echo $?
0

Ignore

/usr/bin/somecommand || /bin/true

Snippet

Basic

RESULT=$?
if [ ${RESULT} -ne 0 ];
then
    echo -e "\nLast command has failed."
else
    echo -e "\nLast command has succeeded."
fi 

One liner

[ "$?" -eq 0 ] && echo success  || echo failure





Discover More
Bash Liste Des Attaques Ovh
Bash - Arithmetic Expression

(()) arithmetic in bash part of compound expression . Counter Simple addition where let is the let command If the value of the expression is: non-zero, the return status is 0; otherwise...
Bash Liste Des Attaques Ovh
Bash - Exit Builtin command

exit is a builtin command and cause the shell to exit with a given exit status. n is the exit status of n. If n is omitted,the exit status is that of the last command executed. A function...
Bash Liste Des Attaques Ovh
Bash - Return - (Function|Shell) exit

Return is a bash builtin function that causes to update the exit status specified by n. Return is intended to be used only for signaling errors, not for returning the results of function. If used:...
Bash Liste Des Attaques Ovh
Bash - Set (of Bash Options)

The set builtin command can be specify shell option. When options are specified, they set or unset shell attributes. Without options, the name and value of each shell variable are displayed in a...
Bash Liste Des Attaques Ovh
Bash - While

This article is dedicated to the while syntax in Bash. where: : is the no-op command; its exit status is always 0 The command: lists the file with the ls executable (ls -l) pipe the...
Card Puncher Data Processing
Shell Data Processing - Pipeline

A pipeline is a succession of command separated by a pipe operator. -- Malcolm Douglas McIlroy - Inventor of pipes and other wonders. The format for a pipeline is...



Share this page:
Follow us:
Task Runner