Skip to content

Instantly share code, notes, and snippets.

@asanchez75
Forked from andrewrcollins/trim.awk
Created March 21, 2020 07:01
Show Gist options
  • Save asanchez75/c8fc1de8e6d6ca232a2abb3948ead369 to your computer and use it in GitHub Desktop.
Save asanchez75/c8fc1de8e6d6ca232a2abb3948ead369 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