|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Splitting the file
Hi Friends, We have a process where we use 11 different files Code:
filename_1 filename_2 and so on to filename11 now we have only 1 file filename_1 if we split the file to 11 files based on KB and use it in our process, will be having any duplicates? not sure how splitting works while spllitting the data in the file. Appreciate if you could explain with an example. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
None will have duplicates Assume the bigfile has 1000 lines, you want 10 with 100 lines each Code:
split -l 100 bigfile smallfile This gives you 10 files named smallfilea, smallfileb.... smalafilej with 100 lines each. Split by bytes: suppose you have bigfile with 10240 bytes, split into small files of 1024 bytes: Code:
split -b 1024 bigfile smallfile Same smallfile names. bigfile is unchanged in either operation. |
| The Following User Says Thank You to jim mcnamara For This Useful Post: | ||
robertbrown624 (05-21-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
thanks a ton i tried splitting let me check if i get the same result while joining them ! ---------- Post updated at 06:50 PM ---------- Previous update was at 06:35 PM ---------- Hi When i tried to join them back got a very bad result. all the lines are misplaced. i have used the below command Code:
cat file1 file2 file3 > newfile |
|
#4
|
|||
|
|||
|
It is a line Code:
split -l command you want not bytes. This assumes the number of lines divides evenly somehow. You show three files, I'm using three. Code:
lines=$(cat bigfile | wc -l) ## uuoc deliberate
while [ $(( $lines % 3 )) -ne 0 ]
do
lines=$(( $lines + 1 ))
done
line_split=$(( $lines / 3 ))
split -l $line_split bigfile smallfileWhen you chop a file that has carriage control (lines) you wreck the lines if you try to split using Code:
split -b |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Splitting a file in to multiple files and passing each individual file to a command | rkrish | Shell Programming and Scripting | 4 | 11-17-2011 04:29 AM |
| File splitting, naming file according to internal field | Leedor | Shell Programming and Scripting | 7 | 09-16-2010 05:19 AM |
| Help with file splitting | Sneeketeeke | UNIX for Dummies Questions & Answers | 8 | 06-24-2010 03:15 PM |
| File Splitting | dncs | Shell Programming and Scripting | 5 | 12-06-2007 06:47 AM |
| [Splitting file] Extracting group of segments from one file to others | ozgurgul | Shell Programming and Scripting | 1 | 09-14-2006 12:17 PM |
|
|