【问题标题】:Find and update email in file在文件中查找和更新电子邮件
【发布时间】:2015-09-27 18:31:51
【问题描述】:

我有输入计划文本文件,我应该从 %first_name%.%last_name%@my.com 更改为 first.lastname_%sequence%@my.com

谁能帮帮我?

input file:
column1,column2,column3,jack.jack@my.com,column5
column1,column2,column3,tom.tom@my.com,column5
column1,column2,column3,mike.mike@my.com,column5
column1,column2,column3,albert.albert@my.com,column5

output file:
column1,column2,column3,first.lastname_1@my.com,column5
column1,column2,column3,first.lastname_2@my.com,column5
column1,column2,column3,first.lastname_3@my.com,column5
column1,column2,column3,first.lastname_4@my.com,column5

【问题讨论】:

  • 您的输入输出不一致,您自己也没有努力解决这个问题。请edit 改进您的问题,并查看How to Ask 以获得一些一般性指示。

标签: linux shell unix sh ksh


【解决方案1】:

您可能正在寻找这样的东西:

count=1
for line in `cat <your_input_file>`; do
    echo $line | sed -r "s/,[A-Za-z0-9._%+-]+@my.com,/,first.lastname_$count@my.com,/"
    count=`expr $count + 1`
done

【讨论】:

  • 谢谢你,但我应该得到 jack.jack@my.com -> first.lastname_1@my.com 和 tom.tom@my.com -> first.lastname_2@my.com 。 ..,
猜你喜欢
  • 2014-09-17
  • 2015-10-15
  • 2021-01-15
  • 1970-01-01
  • 2018-08-11
  • 1970-01-01
  • 2015-08-09
  • 2022-11-24
  • 1970-01-01
相关资源
最近更新 更多