0

i have an existing users ID and wanted to change those IDs to users name for e.g.

UserID.txt

Group1 = 1234,1002,2004
group2 = 3214,0032,6632
1234 = Read
6632 = Write

Input_file.csv

search for column1 and replace with column2 from Input_file.csv

1234 onetofour
1002 ten2
2004 tennyfour
3214 threefouteen
0032 thirtytwo
6632 Sixtytwo

Using the Input_file.csv records, i want to replace IDs to names inside UsersID.txt

Expected Output:

Group1 = onetofour,ten2,tennyfour
group2 = threefouteen,thirtytwo,Sixtytwo
onetofour= Read
Sixtytwo = Write

I prefer shell scripting here, kindly suggest for the same.

Thanks

2
  • As this is not a free coding service, we'd appreciate seeing some attempt first. Don't post it as a comment, image, table or link to off-site service but use text and include it to your original question. Thanks. Commented Sep 7, 2021 at 7:32
  • Hi James, i have already tried this manually on command line using sed. it would be gr8 if U can suggest on the same. Commented Sep 7, 2021 at 10:32

1 Answer 1

1

I love bash and I had some free time.

bash-4.1$ cat UserID.txt
Group1 = 1234,1002,2004
group2 = 3214,0032,6632
1234 = Read
6632 = Write
bash-4.1$ data=$(cat Input_file.csv); awk '{print $1"/"$2}' <<<"$data" | xargs -I {} sed -i 's/{}/g' UserID.txt
bash-4.1$ cat UserID.txt
Group1 = onetofour,ten2,tennyfour
group2 = threefouteen,thirtytwo,Sixtytwo
onetofour = Read
Sixtytwo = Write
bash-4.1$
Sign up to request clarification or add additional context in comments.

2 Comments

Thank U angshuman, i will try this and update :-)
I am able to achieve my goal, Thanx alot :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.