As Aronnok said in a previous post to run multiple commands we have to do this
# date ; who | wc- l
Now suppose you want to maintain a count ofthe number of users logged on, along with a time/date in a log file. This could be accomplished with two commands:
# date >> logfile
# who | wc -l >> logfile
But why have to run two seperate commands though we know the syntax of running multiple commands as
# date; who | wc -l >> logfile
Guess what will happen?? Both commands will run but only the second one will redirect its output to logfile.
A subshell group will combine the commands so they r treated as one unit. To have a subshell we have to place then inside the parenthesis like
# (date; who | wc -l ) >> logfile