Reputation: 11
Looking for a way to remove [11:55:43] [Server thread/INFO]:
from the line below:
[11:55:43] [Server thread/INFO]: Justin has just earned the achievement [Time to Mine!]
Have attempted to do this through using sed but had no luck, as the name Justin can change to another users name depending on who gains an achievement.
Is there a way I can remove [11:55:43] [Server thread/INFO]:
before the users name without having to specify it? Ie. sed from has, but keep the word in front and remove anything ahead of that?
Upvotes: 0
Views: 142
Reputation: 14945
A gawk
.
Source file:
$ cat infile
[11:55:43] [Server thread/INFO]: Justin has just earned the achievement [Time to Mine!]
[11:58:43] [Server thread/INFO]: Martin has just earned the achievement [Time to Mine!]
Code:
$ gawk -F']: ' 'BEGIN{OFS=""}{$1=""}1' infile
Justin has just earned the achievement [Time to Mine!]
Martin has just earned the achievement [Time to Mine!]
Upvotes: 0
Reputation: 10039
sed 's/^\( *\[[^]]*]\)\{2\}: //' YourFile
[...]
]:
in 2 first [...]
content like in your sampleposix compliant (so --posix
with GNU sed)
Upvotes: 0
Reputation: 1363
With sed
:
sed -e 's/^\[[^]]*\][^[]*\[[^]]*\]: //'
That will remove the start of each line if it matches [
(something)]
(something)[
(something)]:
Upvotes: 0
Reputation: 19601
A sed
command to achieve that is:
sed 's/^.*: //'
e.g.
echo '[11:55:43] [Server thread/INFO]: Justin has just earned the achievement [Time to Mine!]' |\
sed 's/^.*: //'
Justin has just earned the achievement [Time to Mine!]
Upvotes: 1
Reputation: 784918
Using sed:
sed 's/\[.*\] \[.*\]: //' file
Justin has just earned the achievement [Time to Mine!]
Upvotes: 1