e-book: Sed One-Liners Explained
|I love writing about programming and I am happy to announce my second e-book called "Sed One-Liners Explained".|
Sed one-liners are short sed scripts for everyday situations in the shell, such as changing line spacing, numbering lines, and converting and deleting text.
For example, the following sed one-liner numbers the lines of a file:
sed = file | sed 'N; s/n/: /'
Here is how it works - it's made out of two sed commands. The first one uses the = command that inserts a line containing the line number before every original line in the file. Then this output gets piped to the second sed command that joins two adjacent lines with the N command. When joining lines with the N command, a newline character n is placed between them. Therefore it uses the s command to replace this newline n with a colon followed by a space ": ".
The e-book is 98 pages long and it explains exactly 100 one-liners. It's divided into the following chapters:
1. Introduction to sed.
2. Line Spacing.
3. Line Numbering.
4. Text Conversion and Substitution.
5. Selective Printing of Certain Lines.
6. Selective Deletion of Certain Lines.
7. Special sed Applications.
Appendix A. Summary of All sed Commands.
Appendix B. Addresses and Ranges.
Appendix C. Debugging sed Scripts with sed-sed.
Did you know that sed was as powerful as any other programming language? Someone even wrote Tetris in it.
After you read the e-book, you'll be able to write your own Tetris if you wanted to.
| read more | mail this link | score:9566 | -pkrumins, September 19, 2011|
More Programming articles...||