Section 5.10. Grouping Commands


[Page 179 (continued)]

5.10. Grouping Commands

Commands may be grouped by placing them between parentheses, which causes them to be executed by a child shell (subshell). The group of commands shares the same standard input, standard output, and standard error channels, and may be redirected and piped as if it were a simple command. Here are some examples:

$ date; ls; pwd > out.txt           ...execute a sequence Wed Feb  2 00:33:12 CST 2005        ...output from date. 
[Page 180]
a.c b.c ...output from ls. $ cat out.txt ...only pwd was redirected. /home/glass $ (date; ls; pwd) > out.txt ...group and then redirect. $ cat out.txt ...all output was redirected. Wed Feb 2 00:33:28 CST 2005 a.c b.c /home/glass $ _





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net