First page Back Continue Last page Graphics
Tags
sed is the stream editor, handy for mass modifications of a file.
Tags are often used in sed to keep some part of the regex being searched for in the result.
Imagine you have a file of the part numbers above and you need to replace an extra digit with the letter 'x'. The regex for this kind of bad entry is
[A-Z]\{2\}[0-9]\{3\}[0-9]
so the full command is
sed 's+\([A-Z]\{2\}[0-9]\{3\}\)[0-9]+\1X+' \ data > data.1
The 's' operator for sed means substitute, but there are more available. See man sed for details.