Ads by Google

Friday, December 12, 2008

How to get information out of a subshell?

The above topic seems to be a pretty common request on the comp.unix.shell newsgroup.  It was for me too, when I was learning shell programming.  Sooner or later, as a noob, you run into that code fragment that doesn't store the values you were sure were getting generated.  Heck, look at all the echo statements, you put in!

It seems to take a bit programming experience to figure out these subshells, processes, command substitution and the like.  The more code you write, the more likely you are going to get into situations where such features are absolutely required for your code to work.

This thread here provides several ways to do it by other coders.