Swastik Udupa Swastik Udupa - 1 month ago 11
Bash Question

Search for a txt file,if it exists append a new line to it.If it doesn't,then create the file

I tried it using the normal commands

echo "${OPTARG}">>~/movie_history.txt


but >> works only if the file exists.
Is there any way I can make this work through shell scripting?

Answer

Just space out >>, some bash shells are sensitive to this.