Skip to content
Advertisement

Use awk command to get information below a pattern

I have a file with a wide range of information and I want to extract some data from here. I only will post here the interesting part. I want to extract IQ and JQ values as well as the J_ij[meV] value which is two lines above. I read this question How to print 5 consecutive lines after a pattern in file using awk where a pattern is used to extract information bellow and I was thinking doing something similar. My initial idea was:

JavaScript

Loop appears not to working

JavaScript

My expected output is:

JavaScript

It comes from the bold words (** **), first line is only indicative.

Advertisement

Answer

Could you please try following. Written and tested with shown examples.

JavaScript

Output will be as follows.

JavaScript
Advertisement