Skip to content

Instantly share code, notes, and snippets.

@crckdns
Forked from andrewrcollins/trim.awk
Created November 15, 2016 02:38
Show Gist options
  • Save crckdns/53e6ed82b6184dc97b138523b01ac8ef to your computer and use it in GitHub Desktop.
Save crckdns/53e6ed82b6184dc97b138523b01ac8ef to your computer and use it in GitHub Desktop.
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
# whatever
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment