2009-06-21

Bash Tutorial: Part 2

For part 2 of my Bash tutorial, I didn't have the time to make it as big as I had wanted, so it's a little shorter. Let's get started.

Displaying file contents
  • cat
    Concatenate files. The cat command can be used to type out the contents of a file or of multiple files. To type out the contets of your /etc/apt/sources.list file, just do:

    $ cat /etc/apt/sources.list

    If you want to type out the contents of multiple files right after each other, just do:

    $ cat file1 file2 file3

  • less
    less is similar to cat for displaying the contents of a single file. However, less is much better than cat for large files. If you use cat on a large file, you will only be able to see the end of the file because the contents would have scrolled out of view and even beyond the scroll buffer. less allows you to scroll through the entire contents of the file with the up and down arrows as well as the page up and page down keys. To use less to display the contents of your /etc/apt/sources.list file, just do:

    $ less /etc/apt/sources.list

That's all for now. Next time we'll be back with part3.

See you next time

No comments:

Post a Comment