for file in `find . -name "*.po"` ; do msgfmt -o `echo $file | sed s/\.po/\.mo/` $file ; done
This code I found is creating multiple MO files in all subdirectories from PO files. At first time, it works well. But when I run it second time;
it shows some syntax error messages. I checked the PO files that the msgfmt is complaining but they were not existing before. They are created after running this code.
For example the file was secpolicy.po but it also created another secpolicy.po file.
What is wrong in that code?
The problem is most likely with the quoting. Since you don’t quote the sed pattern, the shell interprets the backslashes and calls sed as
When you have a file named
secpolicy.po, it will change it tose.molicy.po, which results in a call toTo fix this, change the
sedtoSee the additional single quotes
'and the end of string$.If you have a file
abc.po, it will match the dot\., the stringpoand finally the end of line$, and then replace this match with.mo, resulting inabc.mo