Last active
July 19, 2018 03:39
-
-
Save nobucshirai/8000467 to your computer and use it in GitHub Desktop.
Check difference between a file in a current directory and its backup file in backup directory created by backer.sh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #$Id: Backdiffer.sh,v 1.3 2013-12-07 12:48:18+09 shirai Exp shirai $ | |
| Backdiffer(){ | |
| check_options $@ | |
| check_dir | |
| counter=(`ls $BackDir | wc -w`) | |
| DiffFile="${BackDir}/$((counter-1))_${ArgFile}" | |
| CheckFile="$DiffFile" | |
| while true | |
| do | |
| if [ -f $CheckFile ];then | |
| DiffFile="${CheckFile}" | |
| ((counter++)) | |
| CheckFile="${BackDir}/${counter}_${ArgFile}" | |
| else | |
| break | |
| fi | |
| done | |
| diae diff $ArgFile $DiffFile | |
| } | |
| check_options(){ | |
| usage_msg="\ | |
| Usage: $0 [options] args | |
| Options: | |
| args input transcript text files | |
| -h call this statement | |
| -d dot dirname mode | |
| " | |
| if [ $# = 0 ];then | |
| echo "$usage_msg" | |
| fi | |
| NumOpt=0 | |
| DotMode=0 | |
| while getopts hd option | |
| do | |
| case "$option" in | |
| h) | |
| echo "$usage_msg" | |
| exit 0 | |
| ;; | |
| esac | |
| done | |
| shift $NumOpt | |
| ArgFile=$1 | |
| BackDir="${ArgFile}.dir" | |
| } | |
| check_dir(){ | |
| if [ ! -f "$ArgFile" ];then | |
| echo " PLEASE INPUT A FILE NAME" | |
| exit | |
| fi | |
| if [ -d $BackDir ]; then | |
| DotMode=0 | |
| elif [ -d back/$BackDir ]; then | |
| DotMode=1 | |
| BackDir="back/$BackDir" | |
| else | |
| echo " backer directory was not found." | |
| exit | |
| fi | |
| } | |
| mkdir_idne(){ | |
| if [ ! -d $1 ]; then | |
| mkdir $1 | |
| echo "---> $1 was created." | |
| fi | |
| } | |
| diae(){ | |
| echo $@ | |
| $@ | |
| } | |
| Backdiffer $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment