Skip to content

Instantly share code, notes, and snippets.

@lucagervasi
Forked from andrewrcollins/trim.awk
Created July 10, 2017 13:04
Show Gist options
  • Select an option

  • Save lucagervasi/6247e7ce59353f1d5a30d04bd8614f52 to your computer and use it in GitHub Desktop.

Select an option

Save lucagervasi/6247e7ce59353f1d5a30d04bd8614f52 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