CHAPTER 6.VIEWING TEXT There Are Many Ways

CHAPTER 6.VIEWING TEXT There Are Many Ways

CHAPTER 6.VIEWING TEXT There are many ways to view or otherwise output text. When your intention is to edit the text of a file, open it in a text editor. 6.1 PERUSING TEXT Use less to peruse text, viewing it one screen (or "page") at a time. The less tool works on either files or standard output. zless is identical to less, but you use it to view compressed text files; it allows you to read a compressed text file's contents without having to uncompress it first. 6.1.1 Perusing a Text File To peruse or page through a text file, give the name of the file as an argument to less. To page through the text file `README', type: $ less README RET This command starts less and displays the file `README' on the screen. You can more forward through the document a line at a time by typing @downarrow, and you can move forward through the document a screenful at a time by typing PgDn. To move backward by a line, type @uparrow, and type PgUp to move backward by a screenful. 6.1.2 Perusing Multiple Text Files You can specify more than one file to page through with less, and you can specify file patterns in order to open all of the files that match that pattern. To page through all of the Unix FAQ files in `/usr/doc/FAQ', type: $ less /usr/doc/FAQ/unix−faq−part* RET 6.1.3 Commands Available While Perusing Text The following table gives a summary of the keyboard commands that you can use while paging through text in less. It lists the keystrokes and describes the commands. KEYSTROKE COMMAND @uparrow Scroll back through the text ("up") one line. @downarrow Scroll forward through the text ("down") one line. @leftarrowor@rightarrow Scroll horizontally (left or right) one tab stop; useful for perusing files that contain long lines. PgUporSPC Scroll forward through the text by one screenful PgDn Scroll backward through the text by one screenful. C−l Redraw the screen. /pattern Search forward through the file for lines containing pattern ?pattern Search backward through the file for lines containing pattern < Move to beginning of the file > Move to end of the file H Display a help screen Q Quit viewing the file and exit less. 6.2 OUTPUTTING TEXT The simplest way to view text is to output it to standard output. This is useful for quickly looking at part of a text, or for passing part of a text to other tools in a command line. Many people still use cat to view a text file, especially if it is a very small file. To output all of a file's contents on the screen, use cat and give the file name as an argument. 6.2.1 Showing Non−printing Characters Use cat with the `−v' option to output non−printing characters, such as control characters, in such a way so that you can see them. With this option, cat outputs those characters in hat notation, where they are represented by a `^' and the character corresponding to the actual control character. To peruse the file `translation' with non−printing characters displayed in hat notation, type: $ cat −v translation | less RET The output of cat is piped to less for viewing on the screen. 6.2.2 Outputting a Beginning Part of a Text Use head to output the beginning of a text. By default, it outputs the first ten lines of its input. To output the first ten lines of file `placement−list', type: $ head placement−list RET You can specify as a numeric option the number of lines to output. If you specify more lines than a file contains, head just outputs the entire text. To output the first line of file `placement−list', type: $ head −1 placement−list RET To output the first sixty−six lines of file `placement−list', type: $ head −66 placement−list RET To output a given number of characters instead of lines, give the number of characters to output as an argument to the `−c' option. To output the first character in the file `placement−list', type $ head −c1 placement−list RET 6.2.3 Outputting an Ending Part of a Text The tail tool works like head, but outputs the last part of its input. Like head, it outputs ten lines by default. To output the last ten lines of file `placement−list', type: $ tail placement−list RET To output the last fourteen lines of file `placement−list', type: $ tail −14 placement−list RET It is sometimes useful to view the end of a file on a continuing basis; this can be useful for a "growing" file, a file that is being written to by another process. To keep viewing the end of such a file, use tail with the `−f' ("follow") option. Type C−c to stop viewing the file. To follow the end of the file `access_log', type: $ tail −f access_log RET 6.2.4 Outputting a Middle Part of a Text There are a few ways to output only a middle portion of a text.To output a particular line of a file, use the sed tool. Give as a quoted argument the line number to output followed by `!d'. Give the file name as the second argument. To output line 47 of file `placement−list', type: $ sed '47!d' placement−list RET To output a region of more than one line, give the starting and ending line numbers, separated by a comma. To output lines 47 to 108 of file `placement−list', type: $ sed '47,108!d' placement−list RET To output the tenth line in the file `placement−list', type: $ head placement−list | tail −1 RET 6.2.5 Outputting the Text between Strings Use sed to select lines of text between strings and output either just that section of text, or all of the lines of text except that section. The strings can be words or even regular expressions. To output all the text from file `book−draft' between `Chapter 3' and `Chapter 4', type: $ sed −n '/Chapter 3/,/Chapter 4/p' book−draft RET To output all of the lines of text except those between two patterns, omit the `−n' option. To output all the text from file `book−draft', except that which lies between the text `Chapter 3' and `Chapter 4', type: $ sed '/Chapter 3/,/Chapter 4/p' book−draft RET 6.2.6 Outputting Text in a Dialect There are all kinds of tools that work as filters on text. a filter is a tool that works on standard input, changing it in some way, and then passing it to standard output. To apply the kraut filter to the text in the file `/etc/motd', type: $ cat /etc/motd | kraut RET These commands pass the contents of the file `/etc/motd' to the kraut filter, whose output is then sent to standard output. The contents of `/etc/motd' are not changed. 6.3 STREAMING TEXT Text is displayed streamed on the screen, one word at a time, with pauses between words and Punctuation. Rapid serial visual presentation, or RSVP, is a technique that aims to increase reading speed and comprehension with the use of computer display screens. The average reading time is lowered and comprehension is increased significantly with this technique. GNOME sview is a "streaming viewer" for X; it streams text a word at a time on the screen, at a default rate of 450 words per minute. To view the contents of the text file `alice−in−wonderland' in sview, type: $ sview alice−in−wonderland RET To start streaming the text, either press S once, or left−click on the button marked RSVP. Both S and the RSVP button toggle the streaming; the left and right arrow keys control the speed. Type Q to quit reading and exit sview. The following table lists the keyboard commands used in sview and describes their meaning. KEYSTROKE DESCRIPTION @leftarrow Decrease the stream speed. [GNU INFO BUG: any <> in the preceding line should be the <− arrow key.] @rightarrow Increase the stream speed. [GNU INFO BUG: any <> in the preceding line should be the −> arrow key.] C−o Open a file. C−q Quit viewing text and exit sview. C−w Erase the current text buffer. M−n Move forward to the next word. M−p Move backward to the previous word. S Toggle the streaming of text. X Display the X selection in its own buffer. N Move forward to the next paragraph. P Move backward to the previous paragraph CHAPTER -7 TEXT EDITING Text editing is one of the most fundamental activities of computing on Linux-based systems. There are a lot of text editors to choose from on Linux systems.The majority of editors fit in one of two families of editor: Emacs and Vi. 7.1 CHOOSING THE PERFECT TEXT EDITOR The following table describes some of the more interesting text editors available, and includes information about their special traits and characteristics. TEXT DESCRIPTION EDITOR Ae Anthony's Editor, ae, is a simple, easy−to−use text editor. It has modes to Emulate the behavior of other text editors. Cooledit Cooledit is a popular, fast text editor for use in X; its features include anti−aliased fonts,Unicode support, and extensibility via the Python programming language. DEdit DEdit is a simple editor for use in X with GNOME installed. It can read compressed files and display Japanese characters. Ee Intended to be an editor that novices can begin using immediately, the Easy Editor features pop−up menus.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    37 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us