...
For the sake of having another text file that's somewhat larger - we'll use the Gutenberg King James Bible, which you can store in a text file named gutenbergjames.txt
with with the following command (don't worry, we'll cover this later as well):
Code Block |
---|
|
wget https://www.gutenberg.org/cache/epub/10/pg10.txt -O gutenbergjames.txt |
Viewing Files
To view the text of a file in the terminal, the first command we can use is the cat
command (short for concatenate), which takes in as an argument the file we want to view the text of, and simply prints it all to the terminal:
Note how this works well for short files, but not as well for large files - if you try running cat james.txt
, you'll quickly get a very long output that's hard to understand all in the terminal! Instead, we can use a different command to better parse the output.
One of the oldest commands is the more
command, which can help incrementally show you more of a file at a time:
Here, you can scroll with the arrow keys, and exit by pressing "q". However, the output still remains on the terminal, and scrolling leaves something to be desired. To add on to this, many systems have the less
command, which we recommend:
Many of the controls are the same, but you can now scroll with your mouse/trackpad, and the output isn't left on the terminal at the end.
Info |
---|
If your terminal every gets too cluttered for your liking, you can use the clear command to get clear away the history from the terminal and start a new prompt at the top |