JDT |
FREE Downloads |
|
Introduction to sed |
|||||
|
sed (Stream EDitor) refers to a Unix utility which (a) parses text files and (b) implements a programming language that can apply textual transformations to such files. It reads input files line by line (sequentially), 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 by Lee E. McMahon of Bell Labs, and is available today for most operating systems. UsageThe following example shows a typical use of sed, where the -e option indicates that the sed expression follows: sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName In many versions, the -e is not required to precede the expression. The s stands for substitute. The g stands for global, which means that all matching occurrences in the line would be replaced. The regular expression (i.e. pattern) to be searched is placed after the first delimiting symbol (slash here) and the replacement follows the second symbol. Slash is the conventional symbol. Any other could be used to make syntax more readable if it does not occur in the pattern or replacement. Historysed is one of the very early Unix commands built for command line processing of data files. It evolved as the natural successor to the popular grep command. Cousin to the later AWK, sed allowed powerful and interesting data processing to be done by shell scripts. sed and AWK are often cited as the progenitors and inspiration for Perl. sed's language does not have variables and has only primitive GOTO and branching functionality; nevertheless, the language is Turing-complete. Article source: http://en.wikipedia.org/wiki/Sed Go back to Programming and Web Development Articles home page
|