6.1 Using echo
While tedious, we can write a BASH script line by line using echo
. We simply use the operators >
and >>
to write and append to a file, just like before:
If you decide to write a BASH script in this way, you will have to comment out all the special characters, as otherwise BASH will interpret them already while writing and not only when executing the file.
Note that it is good practice to use the extension “.sh” for files containing BASH scripts. However, Linux doesn’t care about extensions and will also accept a file as a BASH script even if we call it “test.myFantasticFancyFileFormat”.