For Programmers: Free Programming Magazines  


Home > Archive > AWK > November 2005 > Split input file based on size of file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Split input file based on size of file
Karthik

2005-11-07, 9:55 pm

Hello,

Can some one help in creating an output files based on the file size of
the individual files:

I have an input file with complete path of the existing files in a file
system as below:

Input.txt
--------------
/data/volume/admin1/file1.txt
/data/volume/admin1/file2.pdf
/data/volume/admin2/file3.cfg
/data/volume/admin3/file4.cfg

I would like to split the input files based on the file size of the
individual files.

/data/volume/admin1/file1.txt (file size 50 MB)
/data/volume/admin1/file2.pdf (file size 35 MB)
/data/volume/admin2/file3.cfg (file size 75 MB)
/data/volume/admin3/file4.cfg file size 20 MB)

Say (if it exceeds 100 MB size, create a new output file)

Output1.txt
-----------------
/data/volume/admin1/file1.txt
/data/volume/admin1/file2.pdf

Output2.txt
/data/volume/admin2/file3.cfg
/data/volume/admin3/file4.cfg

Thanks in advance.

Ed Morton

2005-11-07, 9:55 pm



Karthik wrote:

> Hello,
>
> Can some one help in creating an output files based on the file size of
> the individual files:
>


This is an OS-specific question rather than an awk language one. You'd
be better posting to whatever NG is specific to your OS, e.g.
comp.unix.shell if you're on UNIX.

Ed.
Atropo

2005-11-07, 9:55 pm


Karthik wrote:
> Hello,
>
> Can some one help in creating an output files based on the file size of
> the individual files:
>
> I have an input file with complete path of the existing files in a file
> system as below:
>
> Input.txt
> --------------
> /data/volume/admin1/file1.txt
> /data/volume/admin1/file2.pdf
> /data/volume/admin2/file3.cfg
> /data/volume/admin3/file4.cfg
>
> I would like to split the input files based on the file size of the
> individual files.
>
> /data/volume/admin1/file1.txt (file size 50 MB)
> /data/volume/admin1/file2.pdf (file size 35 MB)
> /data/volume/admin2/file3.cfg (file size 75 MB)
> /data/volume/admin3/file4.cfg file size 20 MB)
>
> Say (if it exceeds 100 MB size, create a new output file)
>
> Output1.txt
> -----------------
> /data/volume/admin1/file1.txt
> /data/volume/admin1/file2.pdf
>
> Output2.txt
> /data/volume/admin2/file3.cfg
> /data/volume/admin3/file4.cfg
>
> Thanks in advance.


you aren't clear enough, but I'll give you some clues

1-file sizes
ls -la|awk '{sum = sum + $5} END {print sum}'

2-
man split

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com