anthony

anthony / ltrim(), rtrim(), and trim() in awk

Last active 2 months ago

Like 0

Taken from https://gist.github.com/andrewrcollins/1592991

anthony revised this gist 1 year ago · 3d55f75

No changes

anthony revised this gist 1 year ago · 1f85a77

1 file changed, 12 insertions

trim.awk (file created)
@@ -0,0 +1,12 @@
1 + function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
2 + function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
3 + function trim(s) { return rtrim(ltrim(s)); }
4 + BEGIN {
5 + # whatever
6 + }
7 + {
8 + # whatever
9 + }
10 + END {
11 + # whatever
12 + }