Chapter 12
View A File (less, MORE)

To do this exercise you're going to do some work using the commands you know so far. You'll also need a text editor that can make plain text (.txt) files. Here's what you do:

  1. Open your text editor and type some stuff into a new file. On OSX this could be TextWrangler. On Windows this might be Notepad++. On Linux this could be GEdit. Any editor will work.
  2. Save that file to your Desktop and name it ex12.txt.
  3. In your shell use the commands you know to copy this file to your temp directory that you've been working with.

Once you've done that, complete this exercise.

12.1 Do This


Source 21: Linux/Mac OSX Exercise 12
  $ less ex12.txt
  [displays file here]
  $

That's it. To get out of less just type q (as in quit).


Source 22: Windows Exercise 12
  > more ex12.txt
  [displays file here]
  >


Note 4: Abbreviating "displays file here"

In the above output I'm showing [displays file here] to "abbreviate" what that program shows. I'll do this when I mean to say, "Showing you the output of this program is too complex, so just insert what you see on your computer here and pretend I did show it to you." Your screen will not actually show this.


12.2 You Learned This

This is one way to look at the contents of a file. It's useful because, if the file has many lines, it will "page" so that only one screenful at a time is visible. In the "Do More" section you'll play with this some more.

12.3 Do More

  1. Open your text file again and repeatedly copy-paste the text so that it's about 50-100 lines long.
  2. Copy it to your temp directory again so you can look at it.
  3. Now do the exercise again, but this time page through it. On Unix you use the spacebar and w (the letter w) to go down and up. Arrow keys also work. On Windows just hit spacebar to page through.
  4. Look at some of the empty files you created too.
  5. The cp command will overwrite files that already exist so be careful copying files around.


Online Video Course + PDF For $9

For the price of most other course's PDFs only, you can get the full PDF for this class and 2 videos demonstrating the whole book for both Unix/OSX Terminal and Windows PowerShell. The course is self-paced so you can go through it any time you want, as many times as you want.


Signup Now At Udemy.com For $9