#!/usr/local/bin/perl

#
# dbstripleadingspace
# Copyright (C) 1991-1998 by John Heidemann <johnh@isi.edu>
# $Id: dbstripleadingspace,v 1.8 1999/11/23 02:04:29 johnh Exp $
#
# This program is distributed under terms of the GNU general
# public license, version 2.  See the file COPYING
# in $dblibdir for details.
#

sub usage {
    print <<END;
usage: $0
    Strip space before the first column.

    This function is useful when pre-processing 
    incoming data before running dbcolname.

Sample input (from ls -i /etc/passwd*):
 168378 /etc/passwd
 168236 /etc/passwd-
 168230 /etc/passwd.OLD
 168182 /etc/passwd~

Sample command:
cat raw_data | dbstripleadingspace

Sample output:
168378 /etc/passwd
168236 /etc/passwd-
168230 /etc/passwd.OLD
168182 /etc/passwd~
#  | /home/johnh/BIN/DB/dbstripleadingspace
END
    #' font-lock hack
    exit 1;
}


BEGIN {
    $dblibdir = "/usr/local/lib/jdb";
    push(@INC, $dblibdir);
}
require "$dblibdir/dblib.pl";
use DbGetopt;

my(@orig_argv) = @ARGV;
my($prog) = &progname;
my($dbopts) = new DbGetopt("?", \@ARGV);
my($ch);
while ($dbopts->getopt) {
    $ch = $dbopts->opt;
    if (0) {
    } else {
	&usage;
    };
};
$usage if ($#ARGV != -1);

while (<STDIN>) {
	if ($_ =~ /^\#/) {
		print $_;
		next;
	};

	s/^[ 	]+//;
	print $_;
};

print "#  | $prog " . join(" ", @orig_argv) . "\n";
exit 0;

