Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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

If your filenames may contain space or quotes, you should use GNU Parallel http://www.gnu.org/software/parallel/ instead of xargs as xargs can lead to nasty surprises because of the separator problem http://en.wikipedia.org/wiki/Xargs#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: http://www.youtube.com/watch?v=OpaiGYxkSuQ

share|improve this answer
add comment

Your Answer

 
discard

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.