I have a .pot file produced by xgettext on my c++ source code in format:
#: file1.cpp:line
#: file2.cpp:line
msgid "" - empty string
#: file1.cpp:line
#: file2.cpp:line
msgid " \t\n\r" - string contains only spaces
#: file1.cpp:line
#: file2.cpp:line
msgid "real text"
Then i use command like:
grep "#: " "$(POT_FILE)" | sed -e 's/^\(#: \)\(.*)/\2'
to have the only file names and lines to be in the output.
But the thing is that I don't need files for the strings containing only spaces.
It's quite complicated because I have to find the line msgid "" or such just next to the sequence of lines #: blablabla and according to the contents of the string bypass all preceding lines.
Can anybody help with such command?
Thanks!
If I understand you correctly, put the following into an executable file:
If I put the above into an file called
awkoandchmod +x awkothen runawko data.potI get the following:which matches your last section if you convert the "line" values to numbers.
One of the tricks is using
"as the delimiter. If you need to reject lines where msgid contains", then you would have to use more complicated parsing to identify the complete message text.I don't have access to xgettext so I don't know if the comments after the
-in the example bad lines are from you or the program. The the xgettext program outputs them, the delimiter could be altered to" -to test those strings invalid_msgid().