1. Home
  2. /
  3. Awk
  4. /
  5. Reverse String

Reverse String - Awk Typing CST Test

Loading…

Reverse String — Awk Code

Reverses a string.

BEGIN {
	str="HELLO";
	rev="";
	for(i=length(str);i>0;i--) rev=rev substr(str,i,1);
	print rev;
}

Awk Language Guide

AWK is a text-processing and pattern-scanning language designed for data extraction, reporting, and quick scripting on structured text streams. It excels at line-based parsing, field manipulation, and automating command-line data workflows.

Primary Use Cases

  • ▸Log processing and analysis
  • ▸CSV and text file transformations
  • ▸Inline data filtering and extraction
  • ▸Quick scripting and reports
  • ▸Automating shell workflows

Notable Features

  • ▸Pattern-action processing model
  • ▸Automatic field splitting ($1, $2, etc.)
  • ▸Associative arrays (hash maps)
  • ▸Built-in text and regex support
  • ▸One-liners for powerful command-line automation

Origin & Creator

Created in the 1970s by Alfred Aho, Peter Weinberger, and Brian Kernighan at Bell Labs (A, W, K).

Industrial Note

Still widely used in DevOps, data engineering, UNIX systems, log parsing, sysadmin automation, and ETL pipelines.

More Awk Typing Exercises

AWK Counter and Theme ToggleAWK Sum of ArrayAWK FactorialAWK Fibonacci SequenceAWK Prime CheckerAWK Multiplication TableAWK Celsius to FahrenheitAWK Simple Alarm SimulationAWK Random Walk Simulation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher