Created
July 18, 2013 14:16
-
-
Save ryran/6029699 to your computer and use it in GitHub Desktop.
A bash function for making it easy to change the access time of a file
This file contains 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 | |
# (To change mtime instead of atime, switch the -a to -m) | |
atime_change_1month_ago() | |
{ | |
if [[ -e $1 ]]; then | |
month=`date +%m` | |
[ `echo $month|cut -c1` -eq 0 ] && month=`echo $month|cut -c2` | |
month=$((month - 1)) | |
[ `expr length $month` -eq 1 ] && month="0$month" | |
DayHrMin=`date +%d%H%M` | |
touch -a -t ${month}${DayHrMin} "$1" | |
else | |
echo "$1: No such file or directory" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment