shell script to remove a file if it already exist

前端 未结 7 1181
面向向阳花
面向向阳花 2021-01-30 15:43

I am working on some stuff where I am storing data in a file. But each time I run the script it gets appended to the previous file.

I want help on how I can remove the f

7条回答
  •  野性不改
    2021-01-30 16:06

    if [ $( ls ) ]; then rm ; fi

    Also, if you redirect your output with > instead of >> it will overwrite the previous file

提交回复
热议问题