Geek Logbook

Tech sea log book

What $ in shell scripts means?

In this video:

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.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>