dongming6201 2019-03-25 16:34
浏览 97

如何在许多文件中查找和替换字符串

What I need Is to go thru a directory that contains subdirectories. In each second level directory has a third level directory that contains a file with same file name for every second level directory.

In each of those files made in PHP there Is a variable that contains like: appversion = 'YYYYMMDD'. I need to modify this date for each appearance To eg appversion = '20190301'.

How to do this In Shell or with PHP?

Edit: sorry for the malformed question, this is what defines better what I need to do really

I am afraid the question was a little malformed. What I need to do is: 1. To find in all subdirectories a file called "productver.php". 2. In each "productver.php" file find a variable called 'appversion'. 3. Replace the value with a given value that i provide. Example: I provide a date that is "20190324" and I want to change this to the value of all 'appversion' variables. E.g. 'appversion = 20180121' ==> 'appversion = 20190324'. For this reason, I am afraid simple replace is not enough as I only need to replace the part which is on the right side of the "=" character. And I cannot seek for a specific date, because the dates of this variable change. All I know is that I need to replace those dates, on the right side of the "=" sign of variable 'appversion'.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集