With this awk script I can print Nth line after match Pattern
.
awk '/c&&!--c;/Pattern/{c=N}'
Now, I'm trying to print the line when matches Date
and print the 3rd line after matches Time
echo "x
Date:2/19/2021
a
b
Time:
val:14:31:42
val:15:51:35
val:16:28:03
val:17:04:11
z
w" |
awk '/Date/{d=$0}
c&&!--c;/Time/{print d " - "; c=3}'
Date:2/19/2021
val:16:28:03
The script prints what I want but in different line and I'd like to print the output in the same line like this
Date:2/19/2021 - val:16:28:03
How can this be done? Thanks in advance