如何替换从 Linux Shell 脚本中的另一个文件输入的字符串

How to Replace a string taking an input from another file in Linux Shell script

我有一个现有的用户 ID,想将这些 ID 更改为用户名 例如

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

使用 Input_file.csv 记录,我想将 ID 替换为 UsersID.txt

中的名称

预期输出:

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

我更喜欢shell这里的脚本,请提出相同的建议。

谢谢

我喜欢 bash,我有一些空闲时间。

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 "/"}' <<<"$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$