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