I would like to anonymize several related files by replacing the names with an id number.
Example input
file1:
2 simon
4 wesley
5 nikesh
8 sarah
1 jenny
file2:
3 casey
8 jenny
1 alan
1 jessie
5 gordon
9 bill
1 sue
file3
4 jack
2 jenny
6 wesley
8 sarah
6 gordon
1 derek
6 sue
1 jessie
2 pritesh
7 bill
Desired Output
file 1
2 user1
4 user2
5 user3
8 user4
1 user5
file2:
3 user6
8 user5
1 user7
1 user8
5 user9
9 user10
1 user11
file3
4 user12
2 user5
6 user2
8 user4
6 user9
1 user13
6 user11
1 user8
2 user14
7 user10
What I have tried
Though I expect the solution involves arrays, I am struggling to get my head around this problem.
3 user6- why? What's the algorithm for matching ID and names?