0

I have this console command to make substitute in all PHP files in the directory. Then it feeds the xgettext program.

sed "s/\/\/_/_/g" *.php | xgettext -o output.pot --language=PHP - --from-code=UTF-8

How to change it so that sed traverse all PHP files in all subdirectories?

SylvainD
  • 1,743
  • 1
  • 11
  • 27
IH2
  • 21
  • 1
  • you use a tool like `find` or similar. sed can't do directory traversal on it's own – Fredrik Pihl Apr 09 '14 at 16:51
  • @FredrikPihl Yes, I have tried but with no success. Could you please write some code? – IH2 Apr 09 '14 at 16:54
  • 1
    I could but what have you tried and what didn't work for you? :-) – Fredrik Pihl Apr 09 '14 at 16:56
  • @FredrikPihl I have tried for example this: find ./ -type f -exec sed -i "s/\/\/_/_/g" *.php | xgettext -o output.pot --language=PHP - --from-code=UTF-8 I receive several errors (unable to find a file) – IH2 Apr 09 '14 at 17:00
  • 1
    Try `find . -type f -name '*.php' -exec sed 's/python/perl/g' {} \;` use `-i.bak` to make the changes inline – Fredrik Pihl Apr 09 '14 at 17:05
  • @FredrikPihl Thank you, but what will be the command which feeds xgettext? `find . -type f -name *.php -exec sed "s/\/\/_/_/g" {} | xgettext -o output.pot --language=PHP - --from-code=UTF-8` ? – IH2 Apr 09 '14 at 17:16

0 Answers0