Advertisement
cd62131

compare date

Oct 17th, 2018
621
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. # Usage: ./script 201701 201703
  3. From=$(date -d $(sed 's/^\(....\)\(..\).*/\1-\2-01/' <<<$1) +%s)
  4. To=$(date -d $(sed 's/^\(....\)\(..\).*/\1-\2-01/' <<<$2) +%s)
  5. for f in test_*.tar.gz; do
  6.   date=$(date -d $(sed 's/^test_\(....\)\(..\).*/\1-\2-01/' <<<$f) +%s)
  7.   if (( From <= date && date <= To )); then
  8.     echo $f
  9.   fi
  10. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement