Exercises

 < Day Day Up > 

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 (0 9). 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?

     < Day Day Up > 


    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    A Practical Guide to LinuxR Commands, Editors, and Shell Programming
    ISBN: 131478230
    EAN: N/A
    Year: 2005
    Pages: 213

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