Skip to content

Instantly share code, notes, and snippets.

@flxai
Created December 31, 2015 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxai/363614bbea4529be77f1 to your computer and use it in GitHub Desktop.
Save flxai/363614bbea4529be77f1 to your computer and use it in GitHub Desktop.
Sets file system modification time according to files certain contents
#!/bin/bash
grn='\e[0;32m'
red='\e[0;31m'
clr='\e[0m'
for f in $1/*; do
fn=$(basename $f)
# file system time stamp
fsts=$(stat -c%y $f | awk '{print $1}')
# key file time stamp
kfts=$(sed -e '2q;d' $f | sed 's/^# \?//')
# fix timestamp
col=$grn
if [[ "$fsts" != "$kfts" ]]; then
col=$red
touch -d$kfts $f
fi
echo -e "$(printf '%40s' "$fn"): $col$kfts$clr"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment