September 2018
Beginner
186 pages
4h 30m
English
When you enter a simple command that produces output in an interactive Bash session, such as a call to printf, it writes it straight back to your terminal so that you can read it, before returning you to your prompt:
$ printf 'Hello, terminal!\n' Hello, terminal! $
In both an interactive session and a script, you will often want to do something with the output besides printing it to the screen, particularly if you need to save the data permanently for later use. The simplest means of doing this is to save the output to a file.
To accomplish this, we can use one of Bash's redirection operators, the right angled bracket, >, followed by a filename path:
$ printf 'Hello, file!\n' > myfile $
Notice that when we run the printf ...
Read now
Unlock full access