Text processing

Ed

Ed, an interactive, line-oriented text editor, was originally written by Ken Thompson in 1971.
It has two modes, the command mode and the input mode.
Entering the input mode is completed by typing ‘a’ (append), ‘i’ (insert) or ‘c’ (change).
The input mode is terminated by entering a single period (.) on a line.

From Ed forked two lines:

Sed

Sed was developed by Lee E. McMahon in 1973/1974.
sed.sourceforge.net the official site of sed
www.rtfiber.com.tw/~changyj/sed/
www.grymoire.com
A new feature of GNU-sed is in-place editing, which is done with the option -i.
Some usage examples:
Change the date format:
sed 's/\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\3\2\1/'

delete empty lines:
sed -i '/^$/d'

Vi

viman

Modes

ViM is a modal editor.
The three main modes and how to get there:

Normal mode

Command-line mode


Features which are found only in the full installation of Vim
(sometimes only vim-tiny is installed by default)

Meta-characters/regex

Grep

Grep was created by Ken Thompson in 1973 as a standalone application adapted from the regular expression parser he had written for the ed editor he had created.
The name comes from the ed editor command, g/re/p (global / regular expression / print).

Awk

Awk was developed by Aho, Weinberger and Kernighan, hence the name AWK, in 1977, inspired by Grep. awk.info using multiple lines in awk and sed
delete the line break, join lines:
awk 'BEGIN { FS="\n"; RS=""} { gsub("\n", ""); print}' a

symboledvi/exsed/grepawk/egrep
search (left-side)
.xxxxany char
*xxxxnone or more
^xxxxbeginning of line/string
$xxxxend of line/string
\xxxxmask
[]xxxxgroup
\(\)xxxsaves pattern
\1,\2xxxsaved pattern
{}xnumber of
\{\}xxnumber of
\<\>xxbeginning/end of word
+xone or more
?xnone or one
|xor
()xgroups
substitute (right-side)
\xxxxunmasks
\1\2xxxx\(\) or ()
&xxxxsearch pattern
~xxprevious pattern again
%xprevious pattern
\u\Uxxupper case
\l\Lxxlower case
\exxundoes previous \u\l
\Exxundoes previous \U\L
Most Regex which work in Perl work in Vim.
In Vim they require an escape "\"; e.g. "+" in Perl is written as "\+" in vim.
However, "x to y occurences" is written "\{x,y}" in ViM, with a backslash only in the beginning. Other editors: