Skip to content
Advertisement

How to insert a new record(row or line) after the last line of input file using awk?

The marks of the students are given as a table in the following format Name | rollno | marks in exam1 | marks in exam 2 … i.e. There is one record per line and each column is separated by a | (pipe) character.At the end of all the records I want to add extra lines which contains information about max, min mean…So my question is How would one add new record at the end of input file?

Example: Here is a sample input

JavaScript

For which the output is

JavaScript

Advertisement

Answer

JavaScript

repeat for min and whatever else you need to calculate and check the printf formatting flags for whatever spacing you need, if any.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement