More… and Less…. and MORE and less…

 

So before we start this post, we need to download a file to our system. Go to this link blog1.txt in your web browser on your Linux® system and save the web page in your home directory. If you’re using firefox or Chrome, look under the File Menu for Save. Make sure you save the file as text and it will be named blog1.txt. So now we have a file on our system that we created from the web. We could look at the link to find out what’s in the file, but we want to use the command line. We could use cat but the file is a little big. If you try it, the command looks like:

Alpha:~ computerlamp$ cat blog1.txt

So the contents of the file just go vroom past and all you see is the end of the file. So there has to be a better way… …and there is! The command is called more. more allows us to look through a file, one screen at a time. So rather than the vroom of cat we can look at a file much slower. The command looks like:

Alpha:~ computerlamp$ more blog.txt

The output looks like:

Introduction

This blog is going to cover the ins and outs of using Linux® from the
command line.

So before we talk about Linux®, we have to first ask...

...what is Linux®?

Linux® is an operating system.  An operating system is the thing that
makes a computer workable.  Without it, the computer would be unable to
do anything.  No internet access, no games, no nothing.  The operating
system is the framework that allows the computer to actually do things.
Without one, you've really got an expensive machine that can turn on the
fan and make beeps, but do nothing else.

Unix is an operating system that was created back in the mid 1960s to
run on a new type of computer.  It has a long and convoluted
history, but it boils down to 'new computer system fast and spiffy'.
It was so spiffy various people made it so that it could run on other
types of machines.
blog1.txt

Which looks like the first part of the blog post. If you want to see the next part, hit the space bar. Or, if you think “gee, I’ve read this before, I don’t want to read it again”, hit the q key. So let’s try something different. The program /usr/bin/more is the program that’s executed when you type more. Let’s more more. What we get is:

"/usr/bin/more" may be a binary file.  See it anyway?

So more is smart enough to have us read only text files and not binary files. Another command that works instead of more is less. You can more a file or you can less a file.

Leave a Reply

Your email address will not be published. Required fields are marked *