Replace all runs of whitespace with a single space.
Section: grep, egrep, and ripgrep
sed regex replacement
bash
bash
sed -E 's/[[:space:]]+/ /g' file.txtExplanation
Great for one-line normalization tasks.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing grep, egrep, and ripgrep