Issue
i find this regex
sed -i 's/.*\(:.*\)/\1/g' file.txt
for remove before :
but i need remove the :
too, the result apllying this regex in:
[09/11/2020 15:01:37] Name: Hello!
return:
Hello!
but i need only
Hello!
Solution
You can use
sed -i 's/.*: *//' file.txt
This will remove all text up to last :
including :
and all spaces (if any) right after the :
.
See the online demo:
#!/bin/bash
s='[09/11/2020 15:01:37] Name: Hello!'
sed 's/.*: *//' <<< "$s"
# => Hello!
Answered By - Wiktor Stribiżew