# For Jul 19 - Find lines that have the string "Jul 19" in file.txt
Code:
grep "`date '+%b %d'`" file.txt
# For Jul 19 - Find lines that have the string "Jul 12" 7 days ago in file.txt
Code:
grep "`date '+%b %d' --date='7 days ago'`" file.txt
# For Jul 19 - Find lines that have either string "Jul 12" 7 days ago or the string "Jul 19" in file.txt
Code:
grep -E -e "`date '+%b %d'`|`date '+%b %d' --date='7 days ago'`" file.txt
# For first two columns today
Code:
awk -v date="$(date +"%b %d")" '{if ($1" "$2==date) {print $0}}' file.txt
# For first two columns last week
Code:
awk -v date="$(date +"%b %d" --date="7 days ago")" '{if ($1" "$2==date) {print $0}}' file.txt
# For first two columns last week or today
Code:
awk -v date="$(date +"%b %d" --date="7 days ago")" -v date2="$(date +"%b %d")" '{if ($1" "$2==date || $1" "$2==date2) {print $0}}' file.txt
If this helps please add a rep on the left.
Thanks