Created
          December 31, 2015 09:28 
        
      - 
      
- 
        Save flxai/363614bbea4529be77f1 to your computer and use it in GitHub Desktop. 
    Sets file system modification time according to files certain contents
  
        
  
    
      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 | |
| 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