I've got the following file, lets call it user.txt:
2020/06/30 22:02:58 > [+] VALID USERNAME: admin@spookysec.local
2020/06/30 22:03:58 > [+] VALID USERNAME: admin-svc@spookysec.local
2020/06/30 22:04:58 > [+] VALID USERNAME: backup@spookysec.local
2020/06/30 22:05:58 > [+] VALID USERNAME: harry@spookysec.local
2020/06/30 22:06:58 > [+] VALID USERNAME: wrgwrsd@spookysec.local
2020/06/30 22:07:58 > [+] VALID USERNAME: brssdb@spookysec.local
2020/06/30 22:09:58 > [+] VALID USERNAME: a@spookysec.local
2020/06/30 22:10:58 > [+] VALID USERNAME: adm@spookysec.local
2020/06/30 22:11:58 > [+] VALID USERNAME: admifdfdsn@spookysec.local
I want to remove multiple patterns of every line to just get the usernames (e.g. admin, admin-sv) with one username per line. I tried two seperate sed's what worked fine,
sed -r 's/.{16}$//' user.txt > user2.txt
and after that
sed -r 's/.{42}//' user2.txt > user3.txt
but I think there is a faster and sexier way to do that.
Especially this command
sed -r 's/(@\D+)$//' user.txt > user2.txt
doesn't work. I wanted to delete the @ and every character hereafter...
Does anyone have a clue what I did wrong and possibly a solution? It would be best if I can reach my goal with sed or grep.