I would like to remove all leading and trailing spaces and tabs from each line in an output.Is there a simple tool like trim I could pipe my output into?example file:test space at back  test space at frontTAB at end      TAB at frontsome empty lines with differing TABS and spaces: test space at both ends 
how do I trim leading and trailing whitespace from each line of some output?
shell script;text processing;pipe;whitespace
awk '{$1=$1;print}'or shorter:awk '{$1=$1};1'Would trim leading and trailing space or tab characters1 and also squeeze sequences of tabs and spaces into a single space.That works because when you assign something to one of the fields, awk rebuilds the whole record (as printed by print) by joining all fields ($1, ..., $NF) with OFS (space by default).1(and possibly other blank characters depending on the locale and the awk implementation)