Swastik Udupa Swastik Udupa - 1 year ago 92
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download