How to store return value of command in variable in shell

It is often required to store the value returned from execution of a command in shell. Below is the code snippet to store the return value of a command in a variable in shell:

Examples:

Hope you find the information presented here useful. Please let us know your queries or suggestions in the comments section below.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">