Code:
cmd='date | wc' or cmd="date | wc"
$cmd
If this script is executed, an error is generated. The reason written was that "The execution fails because the pipe is not expanded and is passed to date as an argument". What is meant by expansion of pipe. When we execute date | wc on the command line, it goes fine. then | is not treated as an argument. Why?
If I write
Code:
cmd='date | wc' or cmd="date | wc"
eval $cmd
It works. How?