kapott

datetag.sh

Jan 4th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # datetag.sh
  4. # Usage: datetag.sh <filename>
  5. #
  6. # Will rename a file, and prepend ISODate of the last modified stamp
  7. # in front of the filename;
  8. # eg testfile.txt with a last modified timestamp of september 1st, 2018
  9. # will become 20180901_testfile.txt
  10.  
  11. mod_date="$(stat -c %y ${1} | awk '{print $1}')"
  12. mv ${1} ${mod_date}_${1}
Advertisement
Add Comment
Please, Sign In to add comment