I have 2 text files. One is the list of user names along with the company they work on the same line but separated by a tab space. The second is a output from a weekly generated report that includes more information.
The goal is to take the name from the weekly report and replace it with the name and company from the list of user names.
List of user names and companies look like this on a UserList.txt file where it is separated by a tab space.
Name1 Company 1 Name2 Company 2 Name3 Company 3 Name4 Company 4 Name5 Company 5
Weekly output file comes in a Weekly.txt file
I do not know how I can look into the first text file to get the name and company name and replace only that portion on the second text file.
I am looking for the final output to look something like:
So far, I found a way to manually do this using the
sed command. Here is what I have so far:
sed -r 's/Name1/Name1 Company 1/g;s/Name2/Name2 Company 2/g;s/Name3/Name3 Company 3/g;s/Name4/Name4 Company 4/g;s/Name5/Name5 Company 5/g'
This works, but it is not reading into another file and pulling the most up to date information. Please keep in mind I am using cygwin and this is all a part of a bigger script.