Sed using regular expressions

前端 未结 3 1499
借酒劲吻你
借酒劲吻你 2021-01-25 09:53

So basically I have a original list of 1500 names with a 4 digit number associated with each name. I have another file which contains 200 of these 1500 names with a new 4 digit

3条回答
  •  -上瘾入骨i
    2021-01-25 10:05

    Try the following:

    while read old new ; do
      sed -i "s/$old \([^ ]*\)/$new \1/" original.txt
    done < updated_file.txt
    

    Warning: with the -i option it will automatically update your original.txt file. Don't forget to make a backup copy first.

提交回复
热议问题