Question: Hello, how would I Write a piped command using head, tail, sort, cut, and sed to return the date of the latest event in the
Hello, how would I Write a piped command using head, tail, sort, cut, and sed to return the date of the latest event in the file in yyyy/mm/dd format? Here is the Input file (lab0202.csv):
date time protocol ip-address port packet-size
2018-01-01 19:27:19 TCP 11.101.6.64 22 44
2018-04-17 01:35:12 UDP 10.101.7.69 2135 83
2018-05-05 04:26:05 UDP 11.101.6.65 2160 104
2018-08-20 15:43:16 TCP 10.101.7.64 22 113
2018-02-10 02:28:02 UDP 11.101.6.65 2089 68
2018-03-22 00:05:32 TCP 9.101.7.65 23 92
2018-04-24 19:32:47 TCP 9.100.8.65 22 93
2018-05-19 01:22:06 TCP 10.100.7.64 2107 29
2018-04-13 03:51:33 TCP 9.102.8.64 22 32
2018-08-16 21:02:36 UDP 11.100.8.65 2190 17
2018-06-27 00:44:54 UDP 11.101.6.65 2109 73
2018-01-08 07:39:00 TCP 10.101.8.65 22 74
2018-01-22 07:08:54 UDP 9.101.7.65 2165 27
2018-01-11 07:17:44 TCP 11.101.6.65 22 110
2018-01-10 13:14:41 TCP 10.101.7.64 22 89
2018-08-23 13:47:24 UDP 11.100.6.65 2187 93
2018-08-17 06:29:35 TCP 11.101.6.65 2114 66
2018-11-23 02:22:22 UDP 9.100.7.64 2142 118
2018-09-22 22:06:47 TCP 11.101.6.65 22 9
2018-04-04 09:41:43 UDP 9.102.7.64 2116 34
and the expected output file is: 2018/11/23
Also, how would I write a piped command using grep, sort, uniq, tail, wc, and cut to read the provided data file and return the number of unique IP addresses that match the following criteria:
- IP address begins with 11
- Occurred before August 2018
- Occurred at an even numbered hour
- Has a size less than or equal to 100
The input file is:
date time protocol ip-address port packet-size
2018-01-01 19:27:19 TCP 11.101.6.64 22 44
2018-04-17 01:35:12 UDP 10.101.7.69 2135 83
2018-05-05 04:26:05 UDP 11.101.6.65 2160 104
2018-08-20 15:43:16 TCP 10.101.7.64 22 113
2018-02-10 02:28:02 UDP 11.101.6.65 2089 68
2018-03-22 00:05:32 TCP 9.101.7.65 23 92
2018-04-24 19:32:47 TCP 9.100.8.65 22 93
2018-05-19 01:22:06 TCP 10.100.7.64 2107 29
2018-04-13 03:51:33 TCP 9.102.8.64 22 32
2018-08-16 21:02:36 UDP 11.100.8.65 2190 17
2018-06-27 00:44:54 UDP 11.101.6.65 2109 73
2018-01-08 07:39:00 TCP 10.101.8.65 22 74
2018-01-22 07:08:54 UDP 9.101.7.65 2165 27
2018-01-11 07:17:44 TCP 11.101.6.65 22 110
2018-01-10 13:14:41 TCP 10.101.7.64 22 89
2018-08-23 13:47:24 UDP 11.100.6.65 2187 93
2018-08-17 06:29:35 TCP 11.101.6.65 2114 66
2018-11-23 02:22:22 UDP 9.100.7.64 2142 118
2018-09-22 22:06:47 TCP 11.101.6.65 22 9
2018-04-04 09:41:43 UDP 9.102.7.64 2116 34
And the expected output file is: 1
Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
