Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Splitting Files (AIX 5.2)
You are lucky that I like people splitting hairs. There is a system command
which oes precisely what you want. You can name it anything but "mladen".
Here is the source code:
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
# Parse command line options
my $numlines = 66; my $prefix = "sheeps"; my $file;
"n|numlines=s" => \$numlines,
"p|prefix=s" => \$prefix,
"f|file=s" => \$file,
"h|help|?" => \&usage
);
open( INF, "<", $file ) or die "Cannot open $file for reading:$1\n"; while (<INF>) {
if ( $cnt_line == 0 ) {
$chunk = $prefix . "_" . $cnt_file; open( OUTF, ">", $chunk ) or die "Cannot open $chunk for writing:$!\n"; $cnt_file++;
close OUTF; $cnt_line = 0;
sub usage {
print STDERR qq(USAGE:$0 -f <file> -p <piece prefix> -n <lines per
piece>
Default for the piece prefix is "sheeps". Default for the maximum
number of lines per piece is 66. The "file" argument is mandatory.);
exit(0);
}
-- Mladen Gogala A & E TV Network Ext. 1216 > -----Original Message----- > From: Manjula Krishnan [mailto:oradba_la_at_yahoo.com] > Sent: Friday, September 10, 2004 10:26 AM > To: oracle-l_at_freelists.org > Subject: Splitting Files (AIX 5.2) > > > I am trying to split some text files. I know I can use split command. > > Here's what I have done: > > split -l 66 -a 4 93_11_w2.prt 93_11_w2_ > > What this will do is split the original file (93_11_w2.prt) > into 66 line chunks and each chunk will be named > 93_11_w2_aaaa, 93_11_w2_aaab, 93_11_w2_aaac.... > > Is there any way I can make this split the files and name them: > > 93_11_w2_0001, 93_11_w2_0002, 93_11_w2_0003, .... > > Thanks, > > Manjula > > --------------------------------- > Do you Yahoo!? > Yahoo! Mail - 50x more storage than other providers! > > -- > To unsubscribe - > mailto:oracle-l-> request_at_freelists.org&subject=unsubscribe > To > search the > archives - http://www.freelists.org/archives/oracle-l/ > -- To unsubscribe - mailto:oracle-l-request_at_freelists.org&subject=unsubscribe To search the archives - http://www.freelists.org/archives/oracle-l/Received on Fri Sep 10 2004 - 10:12:01 CDT
![]() |
![]() |