Text-processing utilities in Linux

Text processing is different than word processing. In word processing, text is edited and manipulated in a “What-You-See-Is-What-You-Get” (WYSIWYG) environment. This enables you to produce printed copies of the text, complete with features such as graphics and tables.

Linux stores files in plain-text format. This allows you to use different processing, or filtering, utilities on the text. These utilities let you format, analyze, and manipulate text in many different ways. For example, you can format pages and paragraphs, check spelling, add page numbers and headers, and count the lines, words, and characters that a file contains.

Text-processing utilities

text processing utilities
text processing utilities

The general command syntax used for text-processing commands is

command [option ] filename(s)

Reading files
To work with files, you need to know what information they contain. One way of doing this is to use the cat command to display the contents of a file on your terminal screen. This command provides a number of options.

Options for the cat command

text-processing utilities

Viewer commands
A quicker way of viewing the contents of a file is by using viewer commands, which display the information at the start or end of a file. Examples of viewer commands include head and tail.

By default, the head command displays the first 10 lines of a file, and the tail command displays the last 10 lines of a file. Additional options can be used with these commands to view more specific areas of a file. For example, you can use the -n option with the commands to specify the number of lines they must display.

Pager commands
If a particular file is longer than one screen, it may scroll past too quickly for you to read it. You can scroll through documents at your own pace by using pager commands, which display documents one screen at a time. Examples of pager commands include less and more.

The more command is the original pager command and derives from the Berkeley version of UNIX. It enables you to move through a document in a forward direction only.

The less command was developed to replace the more command and provides a wider range of options for viewing files.

Pager command options

pager command option

3 Responses to “Text-processing utilities in Linux”

  1. Najib Hassan September 8, 2009 at 9:09 pm #

    now i know what is (WYSIWYG) lolx

    btw thanks for gr8 posting

  2. Prince of Andalus September 18, 2009 at 4:16 pm #

    i’ve only used “tail /var/log/messages”

    and “more”

  3. deden June 10, 2010 at 3:28 pm #

    ok thanks for information…

Leave a Reply