The ‘substr’ function is a text-processing tool for extracting substring from a string based on a  specific starting position and optional length. The syntax is substr(string, start [, length]). In AWK, the “substr” function is used to extract a portion of a string.