AWK is a pattern-matching language. It searches for a pattern in a file and, upon finding the corresponding match, it…