awk is a full-blown text processing interpreted programming language.

http://www.gnu.org/manual/gawk-3.1.1/gawk.html if you feel like scratching more than the surface