Inspired by the book “The Productive Programmer” I was paying attention more and more on how I actually get things done and how I could better exploit existing shortcuts or faster paths.
Please do not ask why, but I had the following problem: One my PHP-Apps had scattered syntax errors. The question was, how I could locate them in the application. The first attempt was to let Zend Studio analyse the project… This was very slow and contained a lot of information which I actually did not want to see.
So I came up with the following solution:
find -name ‘*.php’ | xargs -i php -l {} | grep ‘Parser error:’
There are 3 parts piped together:
- find: Lists all .php files in your project.
- xargs: Executes one command for each of the lines coming from standard input. The -i flag replaces one line from STDIN with the {}. The php-executalbe has a flag -l (=lowercase L), which lets php check for correct syntax only.
- grep: Filters the output (lots of output like ‘No syntax errors detected in ./includes/show.inc.php’) to the actual information I liked to see: The files which had syntax errors.
From this experience I learned the following:
- Pay attention to flags of commandline tools, even if they do not appear useful at first sight – like the ‘php -l script.php’. They might be very useful when combined via pipe with other commands.
- I understood one more time the power of the commandline and will more often visit man pages of commands.





[...] 4 votesUsing wget to download all files on a page>> saved by ismellrottenflesh 1 days ago2 votesUseful Linux Commands 08/2008>> saved by joshlora2 2 days ago3 votesRequest for Nom-Nom>> saved by chrissa1 8 days ago3 [...]
[...] public links >> xargs xargs tip of the day Saved by john32mac on Sun 19-10-2008 Useful Linux Commands 08/2008 Saved by freefoto on Sun 19-10-2008 How to parallelize anything using xargs & bash Saved by [...]