sd
sd copied to clipboard
`\s+$` matches newline at the end of the file and newlines on empty lines
From Example 2 in the quick guide ("let's trim some trailing whitespace"), sd '\s+$' ''
seems to eat the newline at the end of the file, and newlines on empty lines, but not the newlines on the other lines.
Example: echo -en "test\n\ntest\n" | sd '\s+$' ''
results in "test\ntest"
. Just wondering if this is intended behavior? It strips the whitespace alright, but I did not expect it to touch those newlines.
The equivalent sed
command behaves as I expected: echo -en "test\n\ntest\n" | sed -E 's/\s+$//g'
leaves this input unchanged.