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
}
@michto01
Copy link

michto01 commented Nov 3, 2016

Thx!

@luisco
Copy link

luisco commented Jun 8, 2017

Excellent, thanks

@moijes12
Copy link

Thanks 👍

@kdcc
Copy link

kdcc commented Feb 27, 2018

Fantastic! @

@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