Remove Leading and Trailing Whitespace using gsub in AWK

Remove Leading and Trailing Whitespace using gsub in AWK

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

Leave a Reply

Your email address will not be published. Required fields are marked *