| Summary: | strange behaviour of sed 's/ */ /' w/ or w/o g | ||
|---|---|---|---|
| Product: | Base System | Reporter: | clefevre <clefevre> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
clefevre
2000-08-07 04:50:00 UTC
> $ echo 'a string with spaces' | sed 's/ */ /'
> a string with spaces
This is exactly what you've asked for: the first place which matches / */
(i.e. 0 or more spaces, i.e. the empty string at the beginning of the line) is
replaced with a space.
Similarly with the other 3 examples.
Check up the meaning of "*" in regex(3).
State Changed From-To: open->closed You've shown us some examples of sed(1) doing the right thign. If you need help with regular expressions, there are some pretty keen beans on the freebsd-questions mailing list. :-) |