hello,
I have following input:
Code:
line01 ss7000:3000:296 test 00:00:00 07:01:39 07/09/13
line02 ss7000:3000:331 test 00:00:00 07:38:03 07/02/13
line03 ss7000:3000:574 test 00:00:00 04:21:40 07/12/13
line04 ss7000:3000:656 test 00:00:00 11:30:47 07/12/13
line05 ss7000:3000:725 test 00:00:00 04:17:31 07/17/13
line06 ss7000:3000:873 test 00:00:00 05:13:15 07/26/13
line07 ss7000:3000:956 test 00:00:00 06:34:17 07/25/13
line08 ss7000:3000:963 test 00:00:00 11:13:02 07/25/13
line09 ss7000:3000:968 test 00:00:00 09:29:31 07/25/13
line10 ss7000:3000:1088 test 00:00:00 09:43:37 07/31/13
line11 ss7000:3000:1100 test 00:00:00 10:45:04 07/31/13
line12 ss7000:3000:1108 test 00:00:00 04:10:28 08/01/13
line13 ss7000:3000:1132 test 00:00:00 06:28:48 08/02/13
line14 ss7000:3000:1137 test 00:00:00 10:59:20 08/01/13
line15 ss7000:3000:1138 test 00:00:00 11:01:50 08/01/13
line16 ss7000:3000:1154 test 00:00:00 05:42:58 08/02/13
line17 ss7000:3000:1157 test 00:00:00 06:31:08 08/02/13
line18 ss7000:3000:1158 test 00:00:00 12:52:46 08/05/13
line19 ss7000:3000:1159 test 00:00:00 11:26:15 08/02/13
line20 ss7000:3000:1165 test 00:00:00 08:02:03 08/02/13
line21 ss7000:3000:1177 test 00:00:00 16:00:47 08/02/13
line22 ss7000:3000:1179 test 00:00:00 08:39:54 08/05/13
line23 ss7000:3000:1190 test 00:00:00 11:25:30 08/05/13
line24 ss7000:3000:1192 test 00:00:00 12:36:07 08/05/13
line25 ss7000:3000:1196 prod 00:21:16 05:58:14 08/06/13
line26 ss7000:3000:1217 test 00:00:00 14:14:57 08/05/13
line27 ss7000:3000:1218 test 00:00:00 12:14:11 08/05/13
line28 ss7000:3000:1223 test 00:00:00 12:58:00 08/05/13
line29 ss7000:3000:1233 test 00:00:00 15:52:15 08/05/13
line30 ss7000:3000:1234 prod 00:23:05 05:22:34 08/06/13
line31 ss7000:3000:1236 prod 00:00:49 05:38:02 08/06/13
line32 ss7000:3000:1241 prod 00:04:20 06:31:14 08/06/13
line33 ss7000:3000:1243 prod 00:00:00 06:42:54 08/06/13
line34 ss7000:3000:1244 prod 00:00:02 07:00:45 08/06/13
line35 ss7000:3000:1244 test 00:00:02 07:00:45 08/06/13
line36 ss7000:3000:1244 test 00:00:02 07:00:45 08/05/13
and need to get only lines where 3rd column is exactly "test" and last column is either today or tomorrow date.
I'd like to ask you if the command below will be ok for this case.
Can:
(($NF != d) && ($NF != y))
be replaced be single check for both cases? e.g. ($NF !~ /d|y/) but working?
Code:
$ d=$(date +%D)
$ y=$(TZ=24 date +%D)
$ echo $d $y
08/06/13 08/05/13
$ awk -vd=$d -vy=$y '($3 == "test") && ($NF != d) && ($NF != y)' /tmp/abcd_e|sum
04143 2
$ [red]awk -vd=$d -vy=$y '($3 == "test") && ($NF != d) && ($NF != y)'[/red] /tmp/abcd_e
line01 ss7000:3000:296 test 00:00:00 07:01:39 07/09/13
line02 ss7000:3000:331 test 00:00:00 07:38:03 07/02/13
line03 ss7000:3000:574 test 00:00:00 04:21:40 07/12/13
line04 ss7000:3000:656 test 00:00:00 11:30:47 07/12/13
line05 ss7000:3000:725 test 00:00:00 04:17:31 07/17/13
line06 ss7000:3000:873 test 00:00:00 05:13:15 07/26/13
line07 ss7000:3000:956 test 00:00:00 06:34:17 07/25/13
line08 ss7000:3000:963 test 00:00:00 11:13:02 07/25/13
line09 ss7000:3000:968 test 00:00:00 09:29:31 07/25/13
line10 ss7000:3000:1088 test 00:00:00 09:43:37 07/31/13
line11 ss7000:3000:1100 test 00:00:00 10:45:04 07/31/13
line12 ss7000:3000:1108 test 00:00:00 04:10:28 08/01/13
line13 ss7000:3000:1132 test 00:00:00 06:28:48 08/02/13
line14 ss7000:3000:1137 test 00:00:00 10:59:20 08/01/13
line15 ss7000:3000:1138 test 00:00:00 11:01:50 08/01/13
line16 ss7000:3000:1154 test 00:00:00 05:42:58 08/02/13
line17 ss7000:3000:1157 test 00:00:00 06:31:08 08/02/13
line19 ss7000:3000:1159 test 00:00:00 11:26:15 08/02/13
line20 ss7000:3000:1165 test 00:00:00 08:02:03 08/02/13
line21 ss7000:3000:1177 test 00:00:00 16:00:47 08/02/13
$ awk -vd=$d -vy=$y '($3 == "test") && (($NF != d) && ($NF != y))' /tmp/abcd_e|sum
04143 2
$ awk -vd=$d -vy=$y '($3 == "test") && (($NF == d) && ($NF == y))' /tmp/abcd_e
$ awk -vd=$d -vy=$y '($3 == "test") && (($NF == d) || ($NF == y))' /tmp/abcd_e
line18 ss7000:3000:1158 test 00:00:00 12:52:46 08/05/13
line22 ss7000:3000:1179 test 00:00:00 08:39:54 08/05/13
line23 ss7000:3000:1190 test 00:00:00 11:25:30 08/05/13
line24 ss7000:3000:1192 test 00:00:00 12:36:07 08/05/13
line26 ss7000:3000:1217 test 00:00:00 14:14:57 08/05/13
line27 ss7000:3000:1218 test 00:00:00 12:14:11 08/05/13
line28 ss7000:3000:1223 test 00:00:00 12:58:00 08/05/13
line29 ss7000:3000:1233 test 00:00:00 15:52:15 08/05/13
line35 ss7000:3000:1244 test 00:00:02 07:00:45 08/06/13
line36 ss7000:3000:1244 test 00:00:02 07:00:45 08/05/13