I want to write a shell script that get two files A and B, and get a result like this:File A:user_a tel_a addr_auser_b tel_b addr_bFile B:process_1 user_aprocess_2 user_aprocess_3 user_bAnd the result:user_a process_1 tel_a addr_auser_a process_2 tel_a addr_auser_b process_3 tel_b addr_bHow can i do this? awk or something else?
A shell script for joining two files
text processing;awk;join
join ... join -1 2 -2 1 FileB FileAOutputuser_a process_1 tel_a addr_auser_a process_2 tel_a addr_auser_b process_3 tel_b addr_bThe input files need to be sorted by the key field ... Your example files are already sorted, so there was no need, but otherwise you could incorporate the sort as follows.   join -1 2 -2 1 <(sort -k2 FileB) <(sort FileA)