Nano vs Echo to create files

Screen Link:

Hey everyone,

This course seems to jump into file creation pretty quickly, and the hint and answer offer two different ways to solve this problem.

I like the nano method that the hint suggests to do, it feels very intuitive to create and edit files in this manner, the echo method shown as the answer is confusing to me.

Can someone help explain how they compare and contrast, and how echo can be used in this manner?

Thank you.

Nano is basically a simple text editor but it also provide many additional features like creating a file.
To create a file with nano command use -

$ nano test.txt

Echo is basically used for printing something to the screen like print function in python but you can also rather than printing the text, you can redirect it’s output to a file.
To create a file with echo, you will use -

echo "hello world" > hello.txt

Now if you type

cat hello.txt

it will print " hello world" to the screen.

One more thing, if you just wish to create a file, you can use the touch command

touch hello.txt

this command will only create the hello.txt file for you in the directory/folder you are in than you can use

nano hello.txt

to open and add something to it.