Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. touch -r
  2.  
  3. touch -r *(Dom[1]) .
  4. touch -r **/*(Dom[1]) .
  5.  
  6. touch -r "$(find -mindepth 1 -maxdepth 1 -printf '%T+=%pn' |
  7. sort |tail -n 1 | cut -d= -f2-)" .
  8. touch -r "$(find -mindepth 1 -printf '%T+=%pn' |
  9. sort |tail -n 1 | cut -d= -f2-)" .
  10.  
  11. mostrecent="`stat -c '%Y %n' * | sort -n | tail -n1 | cut -d ' ' -f '2-'`"
  12.  
  13. mostrecent="`ls -t | head -n1`"
  14.  
  15. touch -r "$mostrecent" *
  16.  
  17. touch -r "`ls -t | head -n1`" *
  18.  
  19. #!/bin/bash
  20. if [ -z "$1" ] ; then
  21. echo 'ERROR: Parameter missing. specify the folder!'
  22. exit
  23. fi
  24. #MODE=tail # change to newest file
  25. MODE=head # change to oldest file
  26. for d in "$1"/*/; do
  27. echo "running on $d"
  28. find "$d" -type d -execdir
  29. echo touch --reference="$(find "$d" -mindepth 1 -maxdepth 1 -printf '%T+=%pn'
  30. | sort | "$MODE" -n 1 | cut -d= -f2-)" "$d" ;
  31. # remove echo to really run it
  32. done
  33.  
  34. mkdir /tmp/test
  35. cd /tmp/test
  36. mkdir d1
  37. mkdir d2
  38. touch d1/text1.txt
  39. sleep 1
  40. touch d1/movie1.mov
  41. touch d2/movie2.mov
  42. sleep 1
  43. touch d2/text2.txt
  44. touch notthis.file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement