save 624 B

1234567891011121314151617181920212223242526
  1. # Save the input in the specified file if possible. If the file exists,
  2. # add a numeric suffice, i.e., .1, and increment that until the file
  3. # does not exist. Use the first name found as the file to save.
  4. #
  5. # Typical usage is: xroff -man -fH *.1 | save MAN.PS
  6. #
  7. # Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
  8. # Copyright (c) 1994 Larry McVoy. GPLed software.
  9. # $Id$
  10. eval 'exec perl -Ssw $0 "$@"'
  11. if 0;
  12. $base = $#ARGV == 0 ? shift : "save";
  13. $file = $base;
  14. $ext = 1;
  15. while (-e $file) {
  16. $file = "$base.$ext";
  17. $ext++;
  18. }
  19. warn "Saving in $file\n";
  20. open(FD, ">$file");
  21. while(<>) {
  22. print FD;
  23. }
  24. exit 0;