Forrest logo
back to the awk tool

awk:ai:84bae

How to i extract field using awk when the field is on a line which is the third line down from a known term which awk can use as the pattern
$ awk '/pattern/{getline;getline;getline;print $1}' ${filename}
try on your machine

This command will search for the term 'pattern' in the file.txt, then extract the first field from the third line down from the matching pattern using awk.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • how to i extract field using awk when the field is on a line which is the third line down from a known term which awk can use as the pattern?
back to the awk tool