I\'m using awk \'{gsub(/^[ \\t]+|[ \\t]+$/,\"\"); print;}\' in.txt > out.txt to remove both leading and trailing whitespaces.
awk \'{gsub(/^[ \\t]+|[ \\t]+$/,\"\"); print;}\' in.txt > out.txt
The problem is the output f
Perl could be used:
perl -lpe 's/^\s*(.*\S)\s*$/$1/' in.txt > out.txt
s/foo/bar/ substitute using regular expressions ^ beginning of string \s* zero or more spaces (.*\S) any characters ending with a non-whitespace. Capture it into $1 \s* zero or more spaces $ end of string
s/foo/bar/
^
\s*
(.*\S)
$