PageRenderTime 20ms CodeModel.GetById 17ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Interpreter/delete-if-older.sh

http://github.com/dennisferron/LikeMagic-All
Shell | 42 lines | 29 code | 9 blank | 4 comment | 5 complexity | 0423c4e5668a22ec9d0886833fe017ec MD5 | raw file
 1#!/bin/bash
 2
 3delFile=$1
 4
 5if [ -e $delFile ]; then
 6	: #echo "File to delete is" $delFile
 7else
 8	echo "File does not exist:" $delFile
 9	exit
10fi
11
12delTime=`date -r $delFile +%s`
13echo "Time of file" $delFile "is" $delTime
14
15shift
16
17for checkFile
18do
19	if [ -e $checkFile ]; then
20		: #echo  "File to check is " $checkFile
21	else
22		echo "File does not exist: " $checkFile
23		continue
24	fi
25
26	checkTime=`date -r $checkFile +%s`
27	#echo "Time of file" $checkFile "is" $checkTime
28
29	if [ $delTime -ne $checkTime ]; then
30		if [ $delTime -lt $checkTime ]; then
31			echo "File" $delFile "is older, deleting."
32			rm $delFile
33			exit
34		#else
35			#echo "File" $delFile "is newer."
36		fi
37	else
38		echo "File times are equal."
39	fi
40
41done
42