How do I check if file exists in Makefile so I can delete it?

前端 未结 12 2137
心在旅途
心在旅途 2020-12-02 07:40

In the clean section of my Makefile I am trying to check if the file exists before deleting permanently. I use this code but I receive errors.

What\'s w

12条回答
  •  再見小時候
    2020-12-02 07:54

    Missing a semicolon

    if [ -a myApp ];
    then
      rm myApp
    fi
    

    However, I assume you are checking for existence before deletion to prevent an error message. If so, you can just use rm -f myApp which "forces" delete, i.e. doesn't error out if the file didn't exist.

提交回复
热议问题