Skip to content

Instantly share code, notes, and snippets.

@m00zi
Forked from andrewrcollins/trim.awk
Created April 23, 2019 18:05
Show Gist options
  • Save m00zi/0b496c22bd19d838a3c937affd4e93f5 to your computer and use it in GitHub Desktop.
Save m00zi/0b496c22bd19d838a3c937affd4e93f5 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