Using Awk and Sed

Awk and Sed are ancient text processing tools.

AWK is a programming language that is designed for processing text-based data, either in files or data streams, and was created at Bell Labs in the 1970s.
sed (stream editor) is a Unix utility that parses text files and implements a programming language which can apply textual transformations to such files. It reads input files line by line, applying the operation which has been specified via the command line or a sed script, and then outputs the line. It was developed from 1973 to 1974 as a Unix utility.

It easily to find distributive of these programs for the Windows platform in the Internet, as well as many descriptions and guidelines for their use.

For example, let's consider the simplest situation. You work in a CMS through Web interface for editing the content. You need to view text and provide meaningful accents using the tag <strong>. You decide to create the custom operation TextLab using awk.

1. At the first stage you create file "strong.awk" in the catalog UserActions of TextLab directory and type the following awk script:

BEGIN { RS="\0" } { printf "<strong>" $0 "</strong>" } 

2. At the second stage you are testing the script on the command line. To do this, you navigate to the directory where you installed TextLab and call awk with the-f UserAction\strong.awk option.
Тестирование операции в командной строке
Then type the text and type the symbol of the end of the stream - CTRL+Z. Awk gives the results and exits.

texting awk script

3. If the result you meet, we only have to connect a new action to TextLab.

Similarly, you can configure any "bracket" text transformation with any other tags (<b>...</b>, <i>...</i>), comments of C- language or XML (/* ... */, <!-...->).

Configure the action that will delete all existing tags in selected text, turning it into a simple plain text. Let's use the sed utility and following file sed-script "no-tags.sed".


Check the script at the command prompt, and then connect the new operation to TextLab as shown in the image on the left.

Similarly, you can create an actions using scripting languages PHP and Perl, technology XSLT.