====== AWK - Delete both leading and trailing whitespaces from each line ====== awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }' file.txt ---- ===== Example ===== aaaaa bbbbb ccccc ddddd eeeee returns: aaaaa bbbbb ccccc ddddd eeeee
awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }' file.txt
aaaaa bbbbb ccccc ddddd eeeee