Greetings,
I discovered that commands can be run in a sub shell, via encasing them between parenthesis.
$ ls -l
-- and --
$ (ls -l)
...will both give you the same output.
I understand that the latter runs in a sub shell. What I do not understand is a practical use for using the parenthesis.
Please explain, or please provide an example where using the parenthesis is beneficial.
Thank you.
parenthesis: purpose in the command line
Re: parenthesis: purpose in the command line
This is not a bash programming forum, but here you go:
https://www.tldp.org/LDP/abs/html/subshells.html
FYI: I just googled the answer to your question. If you had done that you would not have to wait for an answer...
P.
https://www.tldp.org/LDP/abs/html/subshells.html
FYI: I just googled the answer to your question. If you had done that you would not have to wait for an answer...
P.
Re: parenthesis: purpose in the command line
Which forum would have been the right one to ask my question. I looked at all of the descriptions, and none were exactly right for this subject.PPC wrote: Tue Jun 30, 2020 5:26 pm This is not a bash programming forum, but here you go:
https://www.tldp.org/LDP/abs/html/subshells.html
FYI: I just googled the answer to your question. If you had done that you would not have to wait for an answer...
P.
I looked at the link that you provided. It explains the purpose of a sub-shell, but offered no practical example where the parenthesis is beneficial. It explained how variables are hidden and not available to the parent shell, etc.
And it was a tough read for me. I am not a Linux expert. I know only the basics.
I do not use google. They, along with Microsoft (especial Windows 10), are the leading spyware companies, the likes of which the world has never seen.
Cheers!
Re: parenthesis: purpose in the command line
The 'dedicated environment' section on that web page is one of the common uses.
e.g.
tar -c -f - ./mystuff | (cd /home/otheruser/tmp; tar -x -f -)
The second tar command has its own working directory. This was common before tar gained a -C option.
Combining output:
(cat a; hd a) > all.txt
And I think "google" means "search on the internet using your favorite search engine". He doesn't care if you actually use google.
e.g.
tar -c -f - ./mystuff | (cd /home/otheruser/tmp; tar -x -f -)
The second tar command has its own working directory. This was common before tar gained a -C option.
Combining output:
(cat a; hd a) > all.txt
And I think "google" means "search on the internet using your favorite search engine". He doesn't care if you actually use google.
Re: parenthesis: purpose in the command line
A web search could tell you that too. I think what PPC is telling you is that forum.mxlinux.org is a support forum specifically for people having problems with the MX and antiX Linux distros, not a gereric computer or programming help forum.Butters wrote: Tue Jun 30, 2020 5:47 pmWhich forum would have been the right one to ask my question. I looked at all of the descriptions, and none were exactly right for this subject.PPC wrote: Tue Jun 30, 2020 5:26 pm This is not a bash programming forum, but here you go:
https://www.tldp.org/LDP/abs/html/subshells.html
FYI: I just googled the answer to your question. If you had done that you would not have to wait for an answer...
P.
Google doesn't have a monopoly on web search engines. https://en.wikipedia.org/wiki/List_of_search_enginesI do not use google. They, along with Microsoft (especial Windows 10), are the leading spyware companies, the likes of which the world has never seen.
Last edited by JayM on Tue Jun 30, 2020 9:22 pm, edited 1 time in total.
Please read the Forum Rules, How To Ask For Help, How to Break Your System and Don't Break Debian. Always include your full Quick System Info (QSI) with each and every new help request.
Re: parenthesis: purpose in the command line
Yes, the above example makes sense to me. Thanks for the help.
But this example...:
...is above my pay grade. I understand tar's function. But I do not understand how the shell will unravel the entire set of instructions.bll wrote: Tue Jun 30, 2020 6:04 pm tar -c -f - ./mystuff | (cd /home/otheruser/tmp; tar -x -f -)
The second tar command has its own working directory. This was common before tar gained a -C option.
I see that it will create a new file in the current directory, and I see after the pipe that the directory gets set and tar extracts the contents of the file. But when all is said and done, do the contents of the tar file wind up in the /home/otheruser/temp directory?
Is that the entirety of your example? Am I understanding it correctly?
I try to minimize assuming what people mean -- especially in a technical forum where some folks are literal to a fault.bll wrote: Tue Jun 30, 2020 6:04 pm
And I think "google" means "search on the internet using your favorite search engine". He doesn't care if you actually use google.
When someone writes use "google", then I lean towards them meaning what they wrote.
I write use "duckduckgo" when suggesting a search engine. Or I write that they should use the search engine of their choice.
On which web page? On this one?:bll wrote: Tue Jun 30, 2020 6:04 pm The 'dedicated environment' section on that web page is one of the common uses.
https://www.tldp.org/
(this is the first time I have been to the above site)
I am not sure what you mean by dedicated environments and common uses.
I do not want to repeat any mistakes. So I am asking in an effort to understand.
Thank you.
Re: parenthesis: purpose in the command line
I agree with you on Gagle and MicroSpy. That's why I Duck it and use MX Linux.Butters wrote: Tue Jun 30, 2020 5:47 pmPPC wrote: Tue Jun 30, 2020 5:26 pm This is not a bash programming forum, but here you go:
https://www.tldp.org/LDP/abs/html/subshells.html
FYI: I just googled the answer to your question. If you had done that you would not have to wait for an answer...
P.
I do not use google. They, along with Microsoft (especial Windows 10), are the leading spyware companies, the likes of which the world has never seen.
Cheers!

I am command line illiterate.
I copy & paste to the terminal. Liars, Wiseguys, Trolls, and those without manners will be added to my ignore list. 


Re: parenthesis: purpose in the command line
The same way "hoover" became a generic term to mean "vacuum", "google" is fast becoming a generic term to mean "do a web search".
https://en.wikipedia.org/wiki/List_of_g ... trademarks
https://en.wikipedia.org/wiki/List_of_g ... trademarks
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400
Re: parenthesis: purpose in the command line
I never use google as a verb.asqwerth wrote: Wed Jul 01, 2020 2:52 am The same way "hoover" became a generic term to mean "vacuum", "google" is fast becoming a generic term to mean "do a web search".
https://en.wikipedia.org/wiki/List_of_g ... trademarks
I never recommend google as a search engine.
I always dissuade people from all google and all Microsoft products, and closed code in general.
I would hope that in a forum, for open-source code, the community would not follow the masses off the google spyware cliff.
If not in a Linux open-source community, then where?
By the way, I do not use Jello, Rollerblade, Xerox, etc.
I use gelatin, in-line skates, copy, etc.
Cheers!

Re: parenthesis: purpose in the command line
As you wish Butters. You're welcome to do whatever you want.
Personally, I use Google. And Kleenex, Coke, Jello, Skillsaw, etc. etc.
I don't see the sense in objecting philosophically to someone suggesting you use "Google". Just go ahead and translate it however you want and move on.
The point was that if you used a search engine you wouldn't have to wait for forum members to comment.
I don't mind the discussion at all. I'm always interested in learning more about the command line.
Seaken64
Personally, I use Google. And Kleenex, Coke, Jello, Skillsaw, etc. etc.
I don't see the sense in objecting philosophically to someone suggesting you use "Google". Just go ahead and translate it however you want and move on.
The point was that if you used a search engine you wouldn't have to wait for forum members to comment.
I don't mind the discussion at all. I'm always interested in learning more about the command line.
Seaken64
MX21-64 XFCE & W11 on Lenovo 330S LT. MX21-KDE & MX21-XFCE on Live USB.
MX18-64 & W7, Fedora on HP Core2 DT
MX21-32 XFCE w/ MX-Fluxbox on P4HT DT w/ antiX21, SUSE Tumbleweed, Q4OS, WXP
antiX21 on Compaq PIII 1 Ghz DT, w/ Debian, MX18FB, W2K
MX18-64 & W7, Fedora on HP Core2 DT
MX21-32 XFCE w/ MX-Fluxbox on P4HT DT w/ antiX21, SUSE Tumbleweed, Q4OS, WXP
antiX21 on Compaq PIII 1 Ghz DT, w/ Debian, MX18FB, W2K