FG
💻 Software

How to match whitespace in sed?

Fresh7 days ago
Mar 15, 2026510226 views
Confidence Score1%
1%

Problem

How can I match whitespace in sed? In my data I want to match all of 3+ subsequent whitespace characters (tab space) and replace them by 2 spaces. How can this be done?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to match whitespace in sed?

Low Risk

The character class will match the whitespace characters and . For example: will substitute every sequence of at least 3 whitespaces with two spaces. REMARK: For POSIX compliance, use the character class instead of , since the latter is a GNU sed extension. See the POSIX specifications for sed and BREs

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment