please write an awk script to display from the sixth to nint
please write an awk script to display from the sixth to ninth records in “loginfile.” Please test your script to make sure the script displays the following information: ics325fa1531 pts/5 10.10.76.114 Thu Oct 15 19:38 - 19:38 (00:00) ics325fa1531 pts/4 10.10.76.114 Thu Oct 15 19:37 - 19:39 (00:02) ics325fa1524 pts/3 10.10.76.100 Thu Oct 15 19:25 - 21:50 (02:24) ics325fa1524 pts/3 10.10.76.100 Thu Oct 15 19:22 - 19:25 (00:03)
Solution
awk \'BEGIN {RS=\"\";FS=\"\ \"} {print $6,$7,$8,$9}\' data.log
Explanation:
--------------
Here in above statement we use BEGIN keyword, which is used when we want to read file line by line.
Then we are specifying that, print all lines in next lines using \ character.
Then we are specifying to print only 6 to 9 lines.
