why sed replace + redirection deletes my file?

前端 未结 3 1342
执笔经年
执笔经年 2021-01-13 06:57

I am using sed to search and replace two strings in a file in bash (GNU sed)

This is the file after

-rw-r--r-- 1 websync www-data 4156 mar 27 12:56 /         


        
3条回答
  •  不思量自难忘°
    2021-01-13 07:07

    This is normal. you can't read and write to the same file in a pipeline like this. (this will fail with other utilities than sed).

    Use the in-place flag -i instead:

    sed -i 's/www-test/www/g' /home/websync/tmp/sitio-oficial/sitios/wp-config.php
    

提交回复
热议问题