Can you please help me on belw awk comparsion which doest not work
cat employee_list
NAME Last-login
Jack 03/25/2013
Maneul 03/26/2013
Eric 03/26/2013
Samuel 03/28/2013
loak 03/29/2013
zac 03/29/2013
this is my awk .. it gives me error
cat employee_list | awk '(($2=='date +"%m/%d/%Y" -d last-monday') || ($2=='date +"%m/%d/%Y" -d last-tuesday')) {print $1}'
( date working fine)
date +"%m/%d/%Y" -d last-monday
03/25/2013
output example
Jack
Maneul
Eric
The date is a string, so in awk there would need to be double quotes around them if you want to compare it do $2
. Although that would work, it would be better to use awk variables (for example through the -v
mechanism) to be able to use shell values inside awk..
1 Like
Jotne
March 31, 2013, 1:22pm
3
awk '$2==d1 || $2==d2 {print$1}' d1="$(date +"%m/%d/%Y" -d last-monday)" d2="$(date +"%m/%d/%Y" -d last-tuesday)" employee_list
Jack
Maneul
Eric
1 Like
while read nm dt; do [ "$dt" == "$(date -d "last-monday" +"%m/%d/%Y")" -o "$dt" == "$(date -d "last-tuesday" +"%m/%d/%Y")" ] && echo $nm; done < employee_list
1 Like