Skip to content

Instantly share code, notes, and snippets.

@andrewrcollins
Created January 11, 2012 04:22
Show Gist options
  • Star 68 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save andrewrcollins/1592991 to your computer and use it in GitHub Desktop.
Save andrewrcollins/1592991 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
}
@RezoApio
Copy link

RezoApio commented Mar 5, 2018

Really useful! Thanks a lot

@noobbbbb
Copy link

Thx!

@LeeYunhang
Copy link

Thank you very much, man.

@aselvan
Copy link

aselvan commented Apr 2, 2023

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment