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 file if it already exists.
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 file if it already exists.
A one liner shell script to remove a file if it already exist (based on Jindra Helcl's answer):
[ -f file ] && rm file
or with a variable: