what would be the best way to remove whitespace only around certain character. Let's say a dash - Some- String- 12345- Here
would become Some-String-12345-Here
. Something like sed 's/\ -/-/g;s/-\ /-/g'
but I am sure there must be a better way.
Thanks!
If you mean all whitespace, not just spaces, then you could try
\s
:Output:
Or use the
[:space:]
character class:Different versions of sed may or not support these, but GNU sed does.
Try:
you can use awk as well
if its just "- " in your example