You can redirect the output of the echo command using the > and >> operators in the terminal.
Using
>to create or overwrite a file:This operator redirects the output to a file. If the file already exists, it will be overwritten.
echo 'hello labex' > redirect.txtThis command creates a file named
redirect.txtwith the content "hello labex".Using
>>to append to a file:This operator appends the output to the end of an existing file without overwriting it.
echo 'labex.io' >> redirect.txtThis command adds "labex.io" to the end of the
redirect.txtfile.
You can then view the contents of the file using the cat command:
cat redirect.txt
This will display both lines you added to the file.
