I'm trying to delete a character that is at the start of the line of multiple string, but, also have another pattern just before the start of the line, which i don't want to delete:
1:string:test...
2:string test
3:etc...
to
1 string:test...
2 string test
3 etc...
Some string can also contain the character :
which make things interesting. So far i tried:
echo "1:test:" | grep -Pv '(?<=\d):'
which does match the :
character (at least it highlight it, so I'm guessing it's matched) but it doesn't get omitted when using the -v
flag, maybe because it's on the same line as the match? (Here i only did experiment on how to match it and remove it instead of replacing it with a space, as the aforementioned example showed)
echo "1:test:" | sed 's/^.:./ /g'
This seems to be the closest i got, but it cut off the rest of the start beside the :
character, which give:
est:
instead of
1 test:
:
(colon); what’s the first one? What do you want to do with input like42:days
,foo:bar
,The quick:brown fox
or:quux
? For that matter, what do you want to do with input that doesn’t contain any colons? Also, you say that you want to delete the colon, but then you show the output you want, and the colons have been replaced by spaces.