Remove Leading and Trailing Whitespace using gsub in AWK

# echo "  this  test   "|awk '{gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); print}'
this  test
Scroll to Top