What is Subshell in Linux?

You are already aware of shell. It is a program that lets you run commands in Linux. Your major interaction with shell is when you are running commands in a terminal. .

Sooner or later you8217ll come across a term called 8216subshell8217 and that may confuse you. .

A subshell is basically a new shell just to run a desired program. A subshell can access the global variables set by the 8216parent shell8217 but not the local variables. Any changes made by a subshell to a global variable is not passed to the parent shell.

Does that make sense Probably not. Let me explain things in detail with examples.

Here8217s a one line script that displays the value of variable 8216var8217.

I set the value of this variable to LHB what do you think will be displayed when the script is run.


Read Full Post

News Link: https://linuxhandbook.com/subshell/.

Linux Chatter is a news aggregator service that curates some of the best Linux, Cloud, Technical Guides, Hardware and Security news. We display just enough content from the original post to spark your interest. If you like the topic, then click on the 'read full post' button to visit the author's website. Use Linux Chatter to find content from amazing authors!

Note: The content provided has been modified and is not displayed as intended by the author. Any trademarks, copyrights and rights remain with the source.

Disclaimer: Linux Chatter sources content from RSS feeds and personal content submissions. The views and opinions expressed in these articles are those of the authors and do not necessarily reflect those of Linux Chatter.