sed


  1. Crush the blank lines from a file and rename the output:
  2. $ cat crush.sed
    #!/bin/sh
    # Takes one file as argument \
    # and removes all blank\
    # lines from it.

    sed '/^[SPACETAB]*$/d' $1 > $1.new

  3. Trim trailing spaces and tabs and rename the output:
  4. $ cat trim.sed
    #!/bin/sh

    sed 's/[SPACETAB]*$//' $1 > $1.new

  5. List all files newer than input file:
  6. $ cat newer
    #!/bin/sh

    /bin/ls -t | sed '/^'$1'$/q'

Ohio Supercomputer Center Advanced Topics in UNIX
Exercise Solutions
3 of 9