Re: [SLUG] Slicing a file

From: Eben King (eben1@tampabay.rr.com)
Date: Fri May 26 2006 - 14:18:22 EDT


On Fri, 26 May 2006, Dylan William Hardison wrote:

> Spake Paul M Foster on Friday, May 26, 2006 at 01:07AM -0400:
>> Here's what I need to do (sometimes): Take a text file and split it into
>> pieces. The split command won't work for this, because the pieces may
>> not be equal. For example, I may want to split an 8000 line file into
>> pieces 2000, 3000 and 3000 lines each. I'm willing to run the same
>> command multiple times with different parameters, but whatever I use
>> needs to be some common command expected to be there on any system. I've
>> looked at split, head and tail. I suspect I can do this with sed or awk,
>> but I'm not very familiar with those two, beyond rudimentary use. Can
>> anyone suggest a solution?
>>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use IO::File;
>
> die "usage: ginsu.pl file lines..." if @ARGV < 2;

See, some people denigrate perl as a "write-only language", but I find this
quite understandable. I couldn't write or debug it, but I can see about how
it works.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
An ASCII character walks into a bar and orders a double. "Having a bad
day?" asks the barman. "Yeah, I have a parity error," replies the ASCII
chrcter. The barman says, "Yeah, I thought you looked a bit off." - Skud

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:25:04 EDT