Suppose I have a file called
names.txt, which contains a list of names and corresponding emails of people in the following format:
FName1 LName1 <firstname.lastname@example.org> FName2 LName2 <email@example.com> FName3 LName3 <firstname.lastname@example.org> FName4 <email@example.com> FName5 MName1 LName4 <firstname.lastname@example.org> FName1 LName1 <email@example.com> ...
What I am trying to accomplish is to output all of the unique people, case-insensitively, based on name (i.e. ignoring email) from
names.txt. So, the output would look like the following:
FName1 LName1 FName2 LName2 FName3 LName3 FName4 FName5 MName1 LName4
Note that the same name can appear multiple times in the file and names can be a mix of lower case characters, upper case characters, numbers, etc. Examples of names that can appear would be: "JoHn sMitH JOnes", "StEve", or "RoB3rt Fro5t"
What I am struggling with is how to just output the unique names without the associated email. I am able to use
grep to match the patterns I am looking to output by using the following:
grep -i "^[A-Za-z0-9]*[ ]*[A-Za-z0-9]*[ ]*[A-Za-z0-9]*" names.txt
However, I am unsure how to use these pattern results and output the unique names while leaving out the email part of each line. Is there some way I can use these
grep results and send them as standard input into some other command? Any feedback or suggestion would be greatly appreciated.