$cmd ='ls -l | grep fileid.php | awk -F "=" \'{if ($2 >= 50) print $2}\''; print $cmd; /// outputs: ls -l | grep fileid.php | awk -F "=" '{if ($2 >= 50) print $2}' // and this command works at bash with output. // now if I do this: @result=`cmd`; //I get: sh: -c: line 0: syntax error near unexpected token `|'