The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Split large file and add header and footer to each file ashish4422 Shell Programming and Scripting 1 04-15-2008 06:12 AM
Split a file with no pattern -- Split, Csplit, Awk madhunk UNIX for Dummies Questions & Answers 10 12-17-2007 12:57 PM
split the file name rinku Shell Programming and Scripting 1 05-28-2007 01:47 AM
Need to split the file getdpg Shell Programming and Scripting 11 09-04-2006 03:08 AM
How to split file by tags inside file? spookyrtd99 Shell Programming and Scripting 1 07-31-2006 12:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-01-2008
aarif aarif is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
how to split a file

Hi everyone,

please forgive my ignorance but I am trying to split a large data file into smaller manageable chunks. The file is approx 1GB in size (maybe a little more). I want to split it into 4 files exactly. I know there is a way in which to split by size but i would like to split by number i.e. i want 4 files specifically...

is this possible?

Thanks!!
  #2 (permalink)  
Old 03-01-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
If you have the size, where's the problem?

Code:
BYTES=`ls -l mybigfile | awk '{ printf("%0.0f\n", $5/4) }'`
split -b $BYTES mybigfile
No?
  #3 (permalink)  
Old 03-01-2008
aarif aarif is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
Quote:
Originally Posted by robotronic View Post
If you have the size, where's the problem?

Code:
BYTES=`ls -l mybigfile | awk '{ printf("%0.0f\n", $5/4) }'`
split -b $BYTES mybigfile
No?
Sorry i realised shortly afterwards how dumb my question was! Yes, i know the file size. What i did was to get wc bigfile

this told me how many rows of data there was. I then divided this number by 4 and then did split -l by that number.

sorry to take up your time :S

Thanks,
asif.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0