%filter does not call the shell, as system() does in C. Thus "sh -c '...'" must be called to get shell functionalities (stderr redirection, pipe, etc.). However, mgp does not take ' into account when word-splitting %filter command-line. Hence the following ends with sh complaining about a syntax error: %filter "sh -c 'ls -l /'" %endfilter