[awk] Print text without a newline after each record

Created on November 30, 2026

Use awk's printf to control where newlines appear. The example joins two input lines and adds one newline at the end.

printf 'apple\nbanana\n' | awk '{printf "%s", $0} END {printf "\n"}'
applebanana

printf "%s", $0 writes each input line without a newline. The END block adds the final newline after processing the input.

Reference

awk Shell command