2つのファイルの新旧を比較する
#!/bin/sh #file_datecmp.sh if [ $# -ne 2 ]; then echo "Usage: file_datecmp.sh file1 file2" exit 1 fi [ -e "$1" ] || { echo "$1 does not exist"; exit 1; } [ -e "$2" ] || { echo "$2 does not exist"; exit 1; } if [ "$1" -nt "$2" ]; then echo "$1 is newer then $2" elif [ "$1" -ot "$2" ]; then echo "$1 is older then $2" else echo "$1 and $2 have exactly the same timestamp." fi
$ ./file_datecmp.sh array.sh arith.sh array.sh is newer then arith.sh