Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My command: git show --pretty="format:" --name-only returns list of files. Then I use xargs to run a shell script on those files:

git show --pretty="format:" --name-only  | xargs -i phpmd $dir/'{}' text codesize,unusedcode,naming

However, I'd like to run that xargs command only on files with .php extension. How to filter the unwanted files?

share|improve this question
up vote 4 down vote accepted
... | grep '\.php$' | ...
share|improve this answer
Thank you Ignacio. – takeshin Sep 1 '10 at 11:01

If your filenames may contain space or quotes, you should use GNU Parallel instead of xargs as xargs can lead to nasty surprises because of the separator problem

git show --pretty="format:" --name-only  | grep '\.php$' | parallel phpmd $dir/{} text codesize,unusedcode,naming

GNU Watch the intro video for GNU Parallel to learn more:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.