Grouping commands



examples/intro/grouping_commands.txt
$ ls -1 build/; ls -1 examples/ | wc
html
linux
linux_v1.00.tar.gz
linux_v1.00_linux.zip
linux_v1.00_windows.zip
       1       1       6

$ (ls -1 build/; ls -1 examples/) | wc
       6       6      82

Without the parantheses, the pipe is only applied to the output of the second command. With the paranetheses, the output of both ls commands are combined and the pipe is applied to that. A subshell is spawned to execute the commands.


examples/intro/grouping_commands_cd.txt
$ pwd
/home/foobar/training/linux

$ (cd ~; pwd)
/home/foobar

$ pwd
/home/foobar/training/linux