e 416 B

1234567891011121314151617181920
  1. #! /bin/bash
  2. # Allow ed to be usd to edit pipe. If a filename is given, just edit that.
  3. #
  4. # Example:
  5. # cat FOO | e > BAR
  6. #
  7. # e foo.txt
  8. #
  9. # TODO:
  10. # - Allow arguments (e.g. treat anything starting with a "-")
  11. # as an argument and pass that to both invocations below
  12. #
  13. FILE=${1:-""}
  14. if [ "${FILE}" ]; then
  15. ed $FILE
  16. else
  17. (F=$(mktemp) ; cat > $F ; ed $F </dev/tty >/dev/tty ; cat $F ; rm $F)
  18. fi