How to check if sed has changed a file

后端 未结 9 1302
难免孤独
难免孤独 2020-12-01 06:57

I am trying to find a clever way to figure out if the file passed to sed has been altered successfully or not.

Basically, I want to know if the file has been changed

9条回答
  •  时光取名叫无心
    2020-12-01 07:19

    I know it is a old question and using awk instead of sed is perhaps the best idea, but if one wants to stick with sed, an idea is to use the -w flag. The file argument to the w flag only contains the lines with a match. So, we only need to check that it is not empty.

提交回复
热议问题