#! /bin/bash cp $1 $1.bak CLEANVERSION_NAME="$1.clean" # echo $1 # Removing lines that will become completely empty after sed operation # http://soft.zoneo.net/Linux/remove_empty_lines.php # http://www.grymoire.com/Unix/Sed.html#uh-30 sed '/ *# -- Missing translation/d' $1 > $CLEANVERSION_NAME mv $CLEANVERSION_NAME $1 # Now we got rid of all the empty lines created by removing "Missing translation" lines # We remove any lines containing "Missing translation" but also containing other stuff cat $1 | sed -e 's/# -- Missing translation:.*$//' > $CLEANVERSION_NAME # Remove comment of form: #Updated 21-Nov-2011 by # The date can be either 1 or 2 digits. It need not be followed by "by " #cat $CLEANVERSION_NAME | sed -e 's/# Updated \d\d-[a-zA-Z]{3}-\d{4} by.*$//' > $1 #cat $CLEANVERSION_NAME | sed -e 's/ *# Updated .* (by.*)?$//' > $1 cat $CLEANVERSION_NAME | sed -e 's/ *# Updated .[0-9]*\-...\-.....*$//' > $1 rm $CLEANVERSION_NAME echo "**** cleaned version $1" echo "**** pre-cleaned original is in $1.bak"