I have several rows of strings, and I want to sort them alphabetically, from the character @ forward.
I give you an example, I have this:
alice@example.com
austin@microsoft.com
berto@example.com
charles@test.com
dorian@microsoft.com
and I expect this output
alice@example.com
berto@example.com
austin@microsoft.com
dorian@microsoft.com
charles@test.com
So that they are sorted by the string after the "@"
Regards!
>Solution :
You can use the sort command for this:
sort -t@ -k2 inputfile
- -t sets the delimiter to the
@character - -k2 use the second column to sort