|
|
1.1 ! root 1: : ! 2: #!/bin/sh ! 3: # zforce: force a z extension on all gzip files so that gzip will not ! 4: # compress them twice. ! 5: # ! 6: # This can be useful for files with names truncated after a file transfer. ! 7: # 12345678901234 is renamed to 123456789012.z ! 8: ! 9: x=`basename $0` ! 10: if test $# = 0; then ! 11: echo "force a '.z' extension on all gzip files" ! 12: echo usage: $x files... ! 13: exit 1 ! 14: fi ! 15: ! 16: res=0 ! 17: for i do ! 18: if test ! -f "$i" ; then ! 19: echo ${x}: $i not a file ! 20: res=1 ! 21: continue ! 22: fi ! 23: test `expr "$i" : '.*[.-]z$'` -eq 0 || continue ! 24: test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue ! 25: ! 26: gzip -t "$i" 2>/dev/null || continue ! 27: ! 28: if test `expr "$i" : '^.............$'` -eq 13; then ! 29: new=`expr "$i" : '\(.*\).$`.z ! 30: else ! 31: new="$i.z" ! 32: fi ! 33: if mv "$i" "$new" 2>/dev/null; then ! 34: echo $i -- replaced with $new ! 35: continue ! 36: fi ! 37: new=`expr "$i" : '\(.*\)..$`.z ! 38: ! 39: if mv "$i" "$new" 2>/dev/null; then ! 40: echo $i -- replaced with $new ! 41: continue ! 42: fi ! 43: res=1; echo ${x}: cannot rename $i to $new ! 44: done ! 45: exit $res
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.