Athletica Project: How can I reverse an echo command?


In the Athletica project, I accidentally ran the command
echo basketball.txt > hockey.txt instead of cat basketball.txt > hockey.txt

Is there a way I can retrieve the overwritten hockey.txt file content? (if I hypothetically needed to).
Or is there a command to undo previous changes?

Thanks in advance :slightly_smiling_face:

Well, there are a couple of options: before using redirect (>) make a backup:

cp hockey.txt hockey.txt.back

or use version control like git.

Hi stetim94, thanks for your reply.

So what youโ€™re saying is that changes are destructive and there is no way to reverse overwritten files other than restore from backups?

Sorry, Iโ€™m new to this and still catching on to basic theory, but I want to understand this so I can have a best practice in place when things inevitably go wrong.

Yes, which is why commands like mv have an -i option, and some people even alias mv to always be interactive.

Working in the command line gives power, but with power comes responsibility. So you need to make backups, or revision with version control software like git