Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. lastfile=""
  4. if [[ ! -e "$1/old/" ]]; then
  5.         mkdir "$1/old/"
  6. fi
  7. for file in $(ls -r $1); do
  8.         stripped=$(echo "$file" | cut -d'-' -f1)
  9.         if [[ "$stripped" == "$lastfile" ]]; then
  10.                 mv "$1/$file" "$1/old/"
  11.         fi
  12.         lastfile=$stripped
  13. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement