Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Split single file into n number of files Post 302552972 by jayan_jay on Tuesday 6th of September 2011 08:44:38 AM
Old 09-06-2011
Here "n" - number of users. In case the line count of infile is not exactly divisible by the number of users, then it ll create a new file with the remainder lines.
Try this ..
Code:
$ wc -l infile | nawk -v n=3 '{print "expr "$1" / "n"|bc" }' | sh | sed 's,^,split -,g;s,$, infile,g' | sh

This User Gave Thanks to jayan_jay For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

split single file into many

Hello, We have a text file with more than 1500 paragraphs. There is a blank line to separate paragraphs. We need to create one text file (with any name but unique) per paragraph. In other words, how can i extract each paragraph and create a separate file with those contents (so 1500 text... (3 Replies)
Discussion started by: prvnrk
3 Replies

2. UNIX for Dummies Questions & Answers

split a single sql file into multiple files

Hi,I have a single sql file containing many create table ddl's.Example: CREATE TABLE sec_afs ( rpt_per_typ_c char(1) NOT NULL, rpt_per_typ_t varchar(20) NULL, LOCK ALLPAGES go EXEC sp_primarykey 'sec_afs', rpt_per_typ_c go GRANT SELECT ON sec_afs TO developer_read_only... (5 Replies)
Discussion started by: smarter_aries
5 Replies

3. UNIX for Dummies Questions & Answers

split a file into a specified number of files

I have been googling on the 'split' unix command to see if it can split a large file into 'n' number of files. Can anyone spare an example or a code snippet? Thanks, - CB (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

4. Shell Programming and Scripting

Split single file into multiple files based on the number in the column

Dear All, I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...): ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies

5. Shell Programming and Scripting

Split the single file lines into multiple files

Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow. INPUT: Input file name A 1 2 3 4 5 6 7 8 9 ........100 Output: 4 output files (x,y,z,w) File x should contains (Skip 4 lines)... (15 Replies)
Discussion started by: subbarao25
15 Replies

6. Shell Programming and Scripting

split a csv file into specified number of files (not lines)

hi, i really need it ...it's not simple to explain but as it's part of a crontab i can't split the file manually...and the file can change every day so the lines are not a good base. example: how to split 1 csv file in 15 files? thank you very much regards :b: (4 Replies)
Discussion started by: 7stars
4 Replies

7. UNIX for Dummies Questions & Answers

How to separate a single column file into files of the same size (i.e. number of rows)?

I have a text file with 1,000,000 rows (It is a single column text file of numbers). I would like to separate the text file into 100 files of equal size (i.e. number of rows). The first file will contain the first 10,000 rows, the second row will contain the second 10,000 rows (rows 10,001-20,000)... (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

Split single file into multiple files using pattern matching

I have one single shown below and I need to break each ST|850 & SE to separate file using unix script. Below example should create 3 files. We can use ST & SE to filter as these field names will remain same. Please advice with the unix code. ST|850 BEG|PO|1234 LIN|1|23 SE|4 ST|850... (3 Replies)
Discussion started by: prasadm
3 Replies

9. UNIX for Dummies Questions & Answers

Split files into smaller ones with 1000 hierarchies in a single file.

input file: AD,00,--,---,---,---,---,---,---,--,--,--- AM,000,---,---,---,---,---,--- AR, ,---,--,---,--- AA,---,---,---,--- AT,--- AU,---,---,--- AS,---,--- AP,---,---,--- AI,--- AD,00,---,---,---, ,---,---,---,---,---,--- AM,000,---,---,--- AR,... (6 Replies)
Discussion started by: kcdg859
6 Replies

10. Shell Programming and Scripting

Split a single file into multiple files based on a value.

Hi All, I have the sales_data.csv file in the directory as below. SDDCCR; SOM ; MD6546474777 ;05-JAN-16 ABC ; KIRAN ; CB789 ;04-JAN-16 ABC ; RAMANA; KS566767477747 ;06-JAN-16 ABC ; KAMESH; A33535335 ;04-JAN-16 SDDCCR; DINESH; GD6674474747 ;08-JAN-16... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies
splitshp(1)						      General Commands Manual						       splitshp(1)

NAME
splitshp - Split Shape into frames or combine frames into Shapes SYNOPSIS
splitshp SHAPE FRAME... splitshp SHAPE DESCRIPTION
Shape files are used for storage of all visible elements (from UI buttons to terrain features) of the games Exult supports. Shapes contain one or more frames. splitshp can be used to combine frames into one file, or split a Shape file into its component frames. The mode of operation is determined by looking at the number of commandline arguments. Exactly one argument means splitting, more than one argument signals a combining operation. Combining Each FRAME names a Shape file typically consisting of only one frame (i.e. subsequent frames are ignored). All these frames are concate- nated and written to the Shape file SHAPE. Splitting SHAPE will be read and split into its component frames. Each of those will be written to its own Shape file. The names of these files are determined by splitting the name of SHAPE before the last dot -- anything before this dot is the STEM, anything else (including the dot) is the PREFIX, which may be empty in case there is no dot in the name. The output files are then named STEM_nnSUFFIX with nn replaced by the frame number. EXAMPLES
splitshp button.shp button-up.shp button-down.shp Packs the (first) two frames from button-up.shp and button-down.shp into the Shape file button.shp splitshp grizzly Unpacks the frames contained in the Shape file grizzly into the (single-frame) Shape files grizzly_00, grizzly_01, grizzly_02, etc. splitshp boar.new.shp Unpacks the frames contained in the Shape file boar.new.shp into the (single-frame) Shape files boar.new_00.shp, boar.new_01.shp, boar.new_02.shp, etc. AUTHOR
This manpage was written by Robert Bihlmeyer. It may be freely redistributed and modified under the terms of the GNU General Public License version 2 or higher. SEE ALSO
exult(6), shp2pcx(1) Exult 2002-03-24 splitshp(1)
All times are GMT -4. The time now is 07:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy