Sponsored Content
Full Discussion: Need help splitting file
Top Forums Shell Programming and Scripting Need help splitting file Post 302432093 by llsmr777 on Thursday 24th of June 2010 12:44:38 AM
Old 06-24-2010
Need help splitting file

I have a file with 58,000 lines
How can I easily split this file into 5 files with 10,000 lines and then the 6th with 8,000.

I need to do this for multiple files with different number of lines but they all need to be split to have 10,000 lines max.

Someone suggested using the split command but from what I understand that will overwrite my currnet file and just create a file with how many lines I specify - which seems would not work since if I used:
split 10,000 input file outputfile

and it overwrites my original, if I make a copy then run it again how does it know to take the next 10,000?

Any help would be appreciated. Thank you in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Splitting file] Extracting group of segments from one file to others

Hi there, I need to split one huge file into separate files if the condition is fulfilled according to that the position between 97 and 98 matches with “IT” at the segment MAS. There is no delimiter file is fix-width with varous line length. Could you please help me how I do split the file... (1 Reply)
Discussion started by: ozgurgul
1 Replies

2. UNIX for Dummies Questions & Answers

Splitting a file based on record sin another file

All, We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g. File1: UHDR 2008112 "25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991... (7 Replies)
Discussion started by: er_ashu
7 Replies

3. Shell Programming and Scripting

splitting the file

Hi , I have one file which has many headers. Say suppose HEDAER ..data DATA DATA ..data ..data HEADER ..data ..data DATA .data HEADER. ..data ..data If there are 3 HEADERS in source file then I need to split the source file into 3 separate file.... (2 Replies)
Discussion started by: tanyaheerani
2 Replies

4. Shell Programming and Scripting

File splitting, naming file according to internal field

Hi All, I have a rather stange set of requirements that I'm hoping someone here could help me with. We receive a file that is actually a concatenation of 4 files (don't believe this would change, but ideally the solution would handle n files). The super-file looks like:... (7 Replies)
Discussion started by: Leedor
7 Replies

5. Shell Programming and Scripting

Splitting a file in to multiple files and passing each individual file to a command

I have an input file with contents like: MainFile.dat: 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 ... (4 Replies)
Discussion started by: rkrish
4 Replies

6. UNIX for Dummies Questions & Answers

Extracting data from one file, based on another file (splitting)

Dear All, I have two files but want to extract data from one based on another... can you please help me file 1 David Tom Ellen and file 2 David|0010|testnamez|resultsz David|0004|testnamex|resultsx Tom|0010|testnamez|resultsz Tom|0004|testnamex|resultsx Ellen|0010|testnamez|resultsz... (12 Replies)
Discussion started by: A-V
12 Replies

7. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

8. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

9. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

10. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
BYTEPREFIX(5)							File Formats Manual						     BYTEPREFIX(5)

NAME
byteprefix - Configuration for display of sizes DESCRIPTION
There are two standard ways to use units in computing: base 10 (1 k = 10^3 = 1 000) and base 2 (1 K = 2^10 = 1 024). Historically, most computer programs have used units in base 2, where 1 KB = 1 024 bytes, 1 MB = 1 048 576 bytes, etc. However, users are more likely to expect and understand sizes in base 10, as this is the norm outside of computing. This configuration file is a method for configuring programs (that use libkibi) to display sizes in the user's preferred style. It can be configured through a configuration file or environment variable (which takes precedence). When not using the "historic" style, IEC-style prefixes (KiB, MiB, etc.) are used for base 2 units, to disambiguate them from base 10 units (kB, MB, etc.). OPTIONS
There are three possible styles (Default: base10): base2 Display all sizes in Base 2 with IEC prefixes. 1 KiB = 1 024 bytes. 1 MiB = 1 024 KiB = 1 048 576 bytes. 1 GiB = 1 024 MiB = 1 048 576 KiB = 1 073 741 824 bytes. base10 Display all sizes in Base 10, except for sizes of RAM, which use base 2 with IEC prefixes. Everything except RAM: 1 kB = 1 000 bytes. 1 MB = 1 000 kB = 1 000 000 bytes. 1 GB = 1 000 MB = 1 000 000 kB = 1 000 000 000 bytes. RAM: 1 KiB = 1 024 bytes. 1 MiB = 1 024 KiB = 1 048 576 bytes. 1 GiB = 1 024 MiB = 1 048 576 KiB = 1 073 741 824 bytes. historic Display all sizes in Base 2, without IEC prefixes. 1 KB = 1 024 bytes. 1 MB = 1 024 KB = 1 048 576 bytes. 1 GB = 1 024 MB = 1 048 576 KB = 1 073 741 824 bytes. Not recommended. This style uses base units 2 with prefixes usually associated with base 10 units. While it uses KB rather than the SI (base 10) kB, there is no such distinction beyond the kilobyte range, and the units are ambiguous. ENVIRONMENT
BYTEPREFIX This environment variable will override the configured or default style. It should just contain one of the style names, listed in OPTIONS above. XDG_CONFIG_HOME The location of the user's configuration files. If not set, it will be assumed to be ~/.config. FILES
The preferred style can be set in a system-wide configuration file and/or in user's own configuration file (which will take precedence). If no configuration file exists, the default style is base10. /etc/byteprefix or XDG_CONFIG_HOME/byteprefix This file should contain a single line: format=style. Lines beginning with # are treated as comments. EXAMPLE
A user wanting base 2 display can set the following in ~/.config/byteprefix: format=base2 SEE ALSO
units(7) libkibi January 2011 BYTEPREFIX(5)
All times are GMT -4. The time now is 08:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy