Skip to content

Instantly share code, notes, and snippets.

@unfo unfo/dayls.sh
Created May 9, 2014

Embed
What would you like to do?
#!/bin/bash
#
# Author: @unfo
#
# Prints files for a given relative day
#
# 0 = today # this is also the default
# -1 = yesterday
# -2 = day before yesterday
DAY_1=0
if [ $# -eq 1 ]; then
DAY_1=$1
fi
DAY_2=$(($DAY_1 + 1))
dtm_1=$(date -d "$DAY_1 day" +%Y-%m-%d)
dtm_2=$(date -d "$DAY_2 day" +%Y-%m-%d)
find . -type f -newermt $dtm_1 ! -newermt $dtm_2
# Example:
# Prints all files from a week ago
# dayls.sh -7 | xargs ls -lth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.