Remove Leading and Trailing Whitespace using gsub in AWKBy dsg_admin / May 19, 2022 # echo " this test "|awk '{gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); print}' this test