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
Just check:
if [ -f file.txt ]; then echo "hello" >> file.txt else echo "No file.txt" >&2 exit 1 fi
There's no way in bash to alter how >> works; it will always (try to) create a file if it doesn't already exist.
bash
>>