CHAPTER 6.VIEWING TEXT There Are Many Ways

Total Page:16

File Type:pdf, Size:1020Kb

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.
Recommended publications
  • GNU Emacs Manual
    GNU Emacs Manual GNU Emacs Manual Sixteenth Edition, Updated for Emacs Version 22.1. Richard Stallman This is the Sixteenth edition of the GNU Emacs Manual, updated for Emacs version 22.1. Copyright c 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \The GNU Manifesto," \Distribution" and \GNU GENERAL PUBLIC LICENSE," with the Front-Cover texts being \A GNU Manual," and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled \GNU Free Documentation License." (a) The FSF's Back-Cover Text is: \You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development." Published by the Free Software Foundation 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA ISBN 1-882114-86-8 Cover art by Etienne Suvasa. i Short Contents Preface ::::::::::::::::::::::::::::::::::::::::::::::::: 1 Distribution ::::::::::::::::::::::::::::::::::::::::::::: 2 Introduction ::::::::::::::::::::::::::::::::::::::::::::: 5 1 The Organization of the Screen :::::::::::::::::::::::::: 6 2 Characters, Keys and Commands ::::::::::::::::::::::: 11 3 Entering and Exiting Emacs ::::::::::::::::::::::::::: 15 4 Basic Editing
    [Show full text]
  • Xemacs User's Manual
    XEmacs User's Manual July 1994 (General Public License upgraded, January 1991) Richard Stallman Lucid, Inc. and Ben Wing Copyright c 1985, 1986, 1988 Richard M. Stallman. Copyright c 1991, 1992, 1993, 1994 Lucid, Inc. Copyright c 1993, 1994 Sun Microsystems, Inc. Copyright c 1995 Amdahl Corporation. Permission is granted to make and distribute verbatim copies of this manual provided the copy- right notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the con- ditions for verbatim copying, provided also that the sections entitled \The GNU Manifesto", \Distribution" and \GNU General Public License" are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled \The GNU Manifesto", \Distribution" and \GNU General Public License" may be included in a translation approved by the author instead of in the original English. i Short Contents Preface ............................................ 1 GNU GENERAL PUBLIC LICENSE ....................... 3 Distribution ......................................... 9 Introduction ........................................ 11 1 The XEmacs Frame ............................... 13 2 Keystrokes, Key Sequences, and Key Bindings ............. 17
    [Show full text]
  • Jargon File, Version 4.0.0, 24 Jul 1996
    JARGON FILE, VERSION 4.0.0, 24 JUL 1996 This is the Jargon File, a comprehensive compendium of hacker slang illuminating many aspects of hackish tradition, folklore, and humor. This document (the Jargon File) is in the public domain, to be freely used, shared, and modified. There are (by intention) no legal restraints on what you can do with it, but there are traditions about its proper use to which many hackers are quite strongly attached. Please extend the courtesy of proper citation when you quote the File, ideally with a version number, as it will change and grow over time. (Examples of appropriate citation form: "Jargon File 4.0.0" or "The on-line hacker Jargon File, version 4.0.0, 24 JUL 1996".) The Jargon File is a common heritage of the hacker culture. Over the years a number of individuals have volunteered considerable time to maintaining the File and been recognized by the net at large as editors of it. Editorial responsibilities include: to collate contributions and suggestions from others; to seek out corroborating information; to cross-reference related entries; to keep the file in a consistent format; and to announce and distribute updated versions periodically. Current volunteer editors include: Eric Raymond [email protected] Although there is no requirement that you do so, it is considered good form to check with an editor before quoting the File in a published work or commercial product. We may have additional information that would be helpful to you and can assist you in framing your quote to reflect not only the letter of the File but its spirit as well.
    [Show full text]
  • The Linux Cookbook: Tips and Techniques for Everyday Use: the Linux Cookbook: Tips and Techniques for Everyday Use
    The Linux Cookbook: Tips and Techniques for Everyday Use: The Linux Cookbook: Tips and Techniques for Everyday Use: Table of Contents The Linux Cookbook: Tips and Techniques for Everyday Use.....................................................................1 Preface ................................................................................................................................................................3 1.0 Format of Recipes ............................................................................................................................4 1.1 Assumptions, Scope, and Exclusions ..............................................................................................5 1.2 Typographical Conventions .............................................................................................................6 1.3 Versions, Latest Edition, and Errata ................................................................................................7 1.4 Acknowledgments ............................................................................................................................8 PART ONE: Working with Linux .................................................................................................................10 2. Introduction .................................................................................................................................................11 2.1 Background and History ................................................................................................................11
    [Show full text]
  • The Linux Cookbook
    The Linux Cookbook The Linux Cookbook Tips and Techniques for Everyday Use Michael Stutz PRESS An imprint of No Starch Press, Inc. San Francisco The Linux Cookbook. Copyright ­c 2001 by Michael Stutz. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechan- ical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed in the United States of America 12345678910–04 03 02 01 Trademarked names are used throughout this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Co-publishers: William Pollock and Phil Hughes Project Editor: Karol Jurado Assistant Editor: Nick Hoff Cover Design: Octopod Studios Typesetting and Design: Michael Stutz Technical Editor: Scott Schwartz Copyeditor: Andy Carroll Proofreader: Elisabeth Beller Distributed to the book trade in the United States by Publishers Group West, 1700 Fourth Street, Berkeley, California 94710, phone: 800-788-3123 or 510-528-1444, fax: 510-528-3444 Distributed to the book trade in Canada by Jacqueline Gross & Associates, Inc., 195 Allstate Parkway, Markham, Ontario L3R 4T8 Canada, phone: 905-477-0722, fax: 905-477-8619 For information on translations or book distributors outside the United States, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 555 De Haro Street, Suite 250, San Francisco, CA 94107 phone: 415-863-9900; fax: 415-863-9950; [email protected]; www.nostarch.com The information in this book is distributed on an “As Is” basis, without warranty.
    [Show full text]
  • Voices from the Open Source Revolution
    Open Sources: Voices from the Open Source Revolution Open Sources: Voices from the Open Source Revolution 1st Edition January 1999 1-56592-582-3, Order Number: 5823 280 pages, $24.95 Twenty Years of Berkeley Unix From AT&T-Owned to Freely Redistributable Marshall Kirk McKusick Early History Ken Thompson and Dennis Ritchie presented the first Unix paper at the Symposium on Operating Systems Principles at Purdue University in November 1973. Professor Bob Fabry, of the University of California at Berkeley, was in attendance and immediately became interested in obtaining a copy of the system to experiment with at Berkeley. At the time, Berkeley had only large mainframe computer systems doing batch processing, so the first order of business was to get a PDP-11/45 suitable for running with the then-current Version 4 of Unix. The Computer Science Department at Berkeley, together with the Mathematics Department and the Statistics Department, were able to jointly purchase a PDP-11/45. In January 1974, a Version 4 tape was delivered and Unix was installed by graduate student Keith Standiford. http://www.oreilly.com/catalog/opensources/book/kirkmck.html (1 of 19) Open Sources: Voices from the Open Source Revolution Although Ken Thompson at Purdue was not involved in the installation at Berkeley as he had been for most systems up to that time, his expertise was soon needed to determine the cause of several strange system crashes. Because Berkeley had only a 300-baud acoustic-coupled modem without auto answer capability, Thompson would call Standiford in the machine room and have him insert the phone into the modem; in this way Thompson was able to remotely debug crash dumps from New Jersey.
    [Show full text]