So I have a list of random websites of the following kind:
rapido21655bonk.a.sweetpotato.net
rapido26230bonk.a.sourpotato.net
rapido29926bonk.b.sourpotato.net
rapido29926bonk.b.sweetpotato.net
rapido30179bonk.a.sweetpotato.net
rapido30648bonk.b.sourpotato.net
rapido30761bonk.c.sweetpotato.net
Now I need a sed string to only leave the number, and take everything else out. What I did was:
sed s/rapido//
to get rid of the first part of it, but for the second part, I could use sed twice to get rid of them both, but I want to know if I can use some kind of or
logic to remove both in one sed. I know I can use sed to match a or b or c
using [abc]
but I want something like that for whole words. So what I did after this was:
sed s/rapido//|sed s/bonk.[abc].sweetpotato.net//
and then I would put another one with just sourpotato.net, but I can't seem to do the following:
sed s/rapido//|sed s/bonk.[abc].(sweet|sour)potato.net//
This doesn't work. It gives me this:
-bash: syntax error near unexpected token
('`
Only replacing the number doesn't not work, because sometimes I might get stuff like rapido22452boonkers.red
which I would want to still have there. I would want to ONLY remove the 2 alternatives sweetpotato.net
OR sourpotato.net
.
[111@111 ~]$ sed s/rapido// sedster|sed 's/bonk.[abc].(sweetpotato|sourpotato).net//'
21655bonk.a.sweetpotato.net
26230bonk.a.sourpotato.net
29926bonk.b.sourpotato.net
29926bonk.b.sweetpotato.net
30179bonk.a.sweetpotato.net
30648bonk.b.sourpotato.net
30761bonk.c.sweetpotato.net