====== 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