By using shell script, I can automate the task and become more lazier :P
List all po files according to date, older to newer, and only contain fuzzy or untranslated message.
sharuzzaman@debian:/kde4-stable/kdebase$ cat -n list.sh
3 for file in `ls -tr *.po`
5 output=`msgfmt -o /dev/null --statistics $file 2>&1`
6 fuzzyuntranslate=`echo $output | grep -e "fuzzy\|untranslated"`
7 if [ "$fuzzyuntranslate" != "" ]
9 echo $file
Let's take a look at the solution, line by line.
Line 1: Declare the script as a Bash script
Line 2: Blank space for clarity
Line 3: This is the starting point of the "for" loop. The command "ls -tr *.po" will list all po files according to date and reversed, which means older to newer. We quote the command in backtick `` because we want the command to be executed, and the output to become the array of file name for variable "file"
Line 4: The "do" is the part in the "for" loop that we process our list of files.
Line 5: Execute the command "msgfmt -o /dev/null --statistics $file 2>&1" and put the result in variable "output". The 2>&1 redirection is required because the output for msgfmt is printed on stderr, not stdout, so we redirect it to stdout in order to capture it.
Line 6: Echo back the variable "output" and check if it contain the word "fuzzy" or "untranslated" using grep. Put the result in variable "fuzzyuntranslated". If the variable "output" did not contain the word that we search for, the variable "fuzzyuntranslated" will be blank. We use "grep -e" because we have regular expression "|" that carry the meaning "or" on the command
Line 7: Check if the variable "fuzzyuntranslated" is not blank (which means either contain fuzzy, untranslated, or both fuzzy and untranslated)
Line 8: Then
Line 9: Print out the file name that match our requirement.
Line 10: Close the if block with fi
Line 11: Close the do block with done
That's it. We have completed our requirement.
The output should be a long list of filename. I can pipe it to "head" to get only the first 10 line of the filename.
sharuzzaman@debian:/kde4-stable/kdebase$ ./list.sh |head
Happy scripting :)