I\'ve seen several answers on SO about how to append to a file if it exists and create a new file if it doesn\'t (echo \"hello\" >> file.txt) or overwrite
echo \"hello\" >> file.txt
For example:
if [ -f "filename" ]; then echo "hello" >>filename fi