#! /bin/sh #================================================================ # datechange # Replace date expressions #================================================================ # set variables LANG=C LC_ALL=C export LANG LC_ALL year=`date '+%Y'` date=`date '+%Y-%m-%d'` fulldate=`date -R` regexsrc='\.(h|c|cc|cpp|cxx|java|pl|pm|pod|xs|rb|rd|py|lua|idl)$' regexman='\.[0-9]$' regexhtml='\.html$' # edit source files find . -type f | egrep "$regexsrc" | while read file do echo "$file" sed "/opyright/ s/\\(20[0-9][0-9]\\)-\\(20[0-9][0-9]\\)/\\1-$year/" "$file" > "$file.tmp" mv -f "$file.tmp" "$file" done # edit manual files find . -type f | egrep "$regexman" | while read file do echo "$file" sed "/\\.TH/ s/\\(20[0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\)/$date/" "$file" > "$file.tmp" mv -f "$file.tmp" "$file" done # edit HTML files find . -type f | egrep "$regexhtml" | while read file do echo "$file" sed -e "/opyright/ s/\\(20[0-9][0-9]\\)-\\(20[0-9][0-9]\\)/\\1-$year/" -e "/
/ s/Last Update: *\\([A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] 20[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] +[0-9][0-9]*\\)/Last Update: $fulldate/" "$file" > "$file.tmp" mv -f "$file.tmp" "$file" done # exit normally exit 0 # END OF FILE