Issue
Suppose $2 is my variable. I have tried going from
awk -F\, '{print $2 ":"}'
to
awk -F\, '{print gsub(/[ \t]+$/, "", $2) ":"}'
But it goes from printing something to printing nothing at all.
Solution
You're printing the result of the gsub
, but gsub
does an in-place modify of $2
instead of returning a modified copy. Call gsub
, then print:
awk -F\, '{gsub(/[ \t]+$/, "", $2); print $2 ":"}'
Answered By - je4d Answer Checked By - Katrina (WPSolving Volunteer)