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!
CodePudding user response:
Instead of using a capture group to copy everything after the :
, replace everything up to the :
with an empty string.
sed -i 's/^.*://' file.txt
CodePudding user response:
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!