Skip to content
>GLB_
Go back

What $ in shell scripts means?

In this video:

https://www.youtube.com/watch?v=o9THkT5ZPi4&t=308s

I saw the weird symbol:

echo $?

When I’m start looking about it on the internet I discovered that a lot of people has asked, and answered the question for a long time.

As you can read in these question and its answer:

This code is useful in order to know the exist status of the last executed command.

In the Bash Reference Manual we can read:

($?) Expands to the exit status of the most recently executed foreground pipeline.

Bash Reference Manual -> Special Parameters

So, if you are in a Unix-like operating systems. When you use ”$?” you’ll received the exit status of the last executed command. The exit status will indicates the success or failure of the command.

A value of 0 indicates success. A non-zero value indicates an error or failure.


Share this post:

Previous Post
SODA: Check count distinct elements
Next Post
Why to choose a Data Lake?