CSCI 344
Sample Sed Problems
Lab 2


Write a sed scripts to do each of the following:
  1. Delete leading whitespace from the front of each line
  2. Delete trailing whitespace from end of each line
  3. Insert 5 blank spaces at the beginning of each line
  4. Substitute "foo" with "bar" ONLY on lines which contain "baz"
  5. Substitute "foo" with "bar" EXCEPT for lines which contain "baz"
  6. change "scarlet" or "ruby" or "puce" to "red"
  7. print first 10 lines of file
  8. print only line which match a regular expression
  9. pirnt all of file EXCEPT section between 2 regular expressions
  10. delete the first 10 lines of a file