How to substitute dates in Perl?

前端 未结 3 1077
甜味超标
甜味超标 2021-01-21 19:12
perl -pi.back -e \'s/2013/07/31-05:54:14/2014/07/31-00:00:00/g;\' /tmp/ranjan/replace.SEL

I\'m using the above one liner to replace the date from

3条回答
  •  滥情空心
    2021-01-21 19:32

    Perl thinks that the forward slashes in your dates are actually part of the substitution statement s///g, so you can either escape the slashes in your dates or use a different delimiter for your substitution

    perl -pi.back -e 's/2013\/07\/31-05:54:14/2014\/07\/31-00:00:00/g;'
    

    or more readable:

    perl -pi.back -e 's#2013/07/31-05:54:14#2014/07/31-00:00:00#g;' 
    

提交回复
热议问题