Exercises


1.

Write a sed command that copies a file to standard output, removing all lines that begin with the word Today.

2.

Write a sed command that copies only those lines of a file that begin with the word Today to standard output.

3.

Write a sed command that copies a file to standard output, removing all blank lines (lines with no characters on them).

4.

Write a sed program named ins that copies a file to standard output, changing all occurrences of cat to dog and preceding each modified line with a line that says following line is modified.

5.

Write a sed program named div that copies a file to standard output, copies the first five lines to a file named first, and copies the rest of the file to a file named last.

6.

Write a sed command that copies a file to standard output, replacing a single SPACE as the first character on a line with a 0 (zero) only if the SPACE is immediately followed by a number (09). For example:

abc   abc  abc   abc  85c  085c 55b   55b  000  0000


7.

How can you use sed to triple-space (i.e., add two blank lines after each line in) a file?




A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net