source: tags/ms_r16q3/SOURCE_TOOLS/mv_if_diff

Last change on this file was 3059, checked in by westram, 20 years ago

improved help

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 553 bytes
Line 
1#!/bin/bash
2
3if [ -z "$2" ] ; then
4    echo "Usage: mv_if_diff source target"
5    echo "Moves source to target."
6    echo "If target does not differ from source, target is kept untouched."
7    echo "If target does not exist, source is always moved to target."
8    echo "source always gets removed."
9    exit 1
10fi
11   
12if [ -f "$2" ]; then   
13    DIFF=`diff $1 $2 | wc -l`
14    if [ $DIFF = 0 ] ; then
15        echo "$2 did not change."
16        rm $1
17    else
18        echo "$2 updated."
19        mv $1 $2
20    fi
21else
22    echo "$2 created."
23    mv $1 $2
24fi
Note: See TracBrowser for help on using the repository browser.