Split a large textfile (one file) into multiple file to base on ^L


 
Thread Tools Search this Thread
Operating Systems Linux Split a large textfile (one file) into multiple file to base on ^L
# 1  
Old 03-11-2016
Split a large textfile (one file) into multiple file to base on ^L

Hi,

Anyone can help, I have a large textfile (one file), and I need to split into multiple file to break each file into ^L.

My textfile

==========
Code:
abc company
abc address
abc contact
^L
my company
my address
my contact
my skills
^L
your company
your address

==========

Need an output like in 3 files ( filename1.txt, filename2.txt, filename3.txt)

1) output filename1.txt
Code:
abc company
abc address
abc contact

2) output filename2.txt
Code:
my company
my address
my contact
my skills

3) output filename3.txt
Code:
your company
your address

Thank you in advance.

Regards,
FSPalero

Last edited by Scrutinizer; 03-11-2016 at 04:09 AM.. Reason: Code tags..
# 2  
Old 03-11-2016
Any attempts/ideas/thoughts from your side?

Is that a literal ^L string (two char sequence), or is it a control char <CTRL>L (form feed, 0X0C)?

---------- Post updated at 11:10 ---------- Previous update was at 11:08 ----------

And, is it on a line of its own, or is it dispersed in the text?

---------- Post updated at 11:55 ---------- Previous update was at 11:10 ----------

Howsoever, try
Code:
awk -vRS=$'\f' '{gsub ("^\012", ""); print > "filename" NR ".txt"}' ORS="" file
cf *.txt
filename1.txt:
abc company
abc address
abc contact
filename2.txt:
my company
my address
my contact
my skills
filename3.txt:
your company
your address

# 3  
Old 03-11-2016
Hi.

See also:
Code:
NAME
       csplit - split a file into sections determined by context lines

SYNOPSIS
       csplit [OPTION]... FILE PATTERN...

DESCRIPTION
       Output  pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01',
       ..., and output byte counts of each piece to standard output.

There are more than 100 threads here that mention csplit, many with demonstrations.

Best wishes ... cheers, drl
# 4  
Old 04-14-2016
hi,

thank you for the response, i forgot to say thank you for you guys. rudic, you gave a good solution for me. many many thanks

regards,
fspalero
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Trying To Split a Large File

Trying to split a 35gb file into 1000mb parts. My research shows I should you this. split -b 1000m file.txt and my return is "split: cannot open 'crunch1.txt' for reading: No such file or directory" so I tried split -b 1000m Documents/Wordlists/file.txt and I get nothing other than the curser just... (3 Replies)
Discussion started by: sub terra
3 Replies

2. Shell Programming and Scripting

Split a content in a file with specific interval base on the delimited values using UNIX command

Hi All, we have a requirement to split a content in a text file every 5 rows and write in a new file . conditions: if 5th line falls between center of the statement . it should look upto after ";" files are below format: 1 UPDATE TABLE TEST1 SET VALUE ='AFDASDFAS' 2 WHERE... (3 Replies)
Discussion started by: KK230689
3 Replies

3. Shell Programming and Scripting

Split Big XML file Base on tag

HI I want to split file base on tag name. I have few header and footer on file <?xml version="1.33" encing="UTF-8"?> <bulkCmConfigDataFile" <xn:SubNetwork id="ONRM_ROOT"> <xn:MeContext id="PPP04156"> ... (4 Replies)
Discussion started by: pareshkp
4 Replies

4. UNIX for Beginners Questions & Answers

sed awk: split a large file to unique file names

Dear Users, Appreciate your help if you could help me with splitting a large file > 1 million lines with sed or awk. below is the text in the file input file.txt scaffold1 928 929 C/T + scaffold1 942 943 G/C + scaffold1 959 960 C/T +... (6 Replies)
Discussion started by: kapr0001
6 Replies

5. Shell Programming and Scripting

Split large zone file dump into multiple files

I have a large zone file dump that consists of ; DNS record for the adomain.com domain data1 data2 data3 data4 data5 CRLF CRLF CRLF ; DNS record for the anotherdomain.com domain data1 data2 data3 data4 data5 data6 CRLF (7 Replies)
Discussion started by: Bluemerlin
7 Replies

6. Shell Programming and Scripting

Split large file into smaller file

hi Guys i need some help here.. i have a file which has > 800,000 lines in it. I need to split this file into smaller files with 25000 lines each. please help thanks (1 Reply)
Discussion started by: sitaldip
1 Replies

7. Shell Programming and Scripting

Split a large file

I have a 3 GB text file that I would like to split. How can I do this? It's a giant comma-separated list of numbers. I would like to make it into about 20 files of ~100 MB each, with a custom header and footer. The file can only be split on commas, but they're plentiful. Something like... (3 Replies)
Discussion started by: CRGreathouse
3 Replies

8. Shell Programming and Scripting

Split Large File

HI, i've to split a large file which inputs seems like : Input file name_file.txt 00001|AAAA|MAIL|DATEOFBIRTHT|....... 00001|AAAA|MAIL|DATEOFBIRTHT|....... 00002|BBBB|MAIL|DATEOFBIRTHT|....... 00002|BBBB|MAIL|DATEOFBIRTHT|....... 00003|CCCC|MAIL|DATEOFBIRTHT|.......... (1 Reply)
Discussion started by: AMARA
1 Replies

9. Shell Programming and Scripting

Split large file and add header and footer to each file

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (1 Reply)
Discussion started by: ashish4422
1 Replies

10. Shell Programming and Scripting

Split A Large File

Hi, I have a large file(csv format) that I need to split into 2 files. The file looks something like Original_file.txt first name, family name, address a, b, c, d, e, f, and so on for over 100,00 lines I need to create two files from this one file. The condition is i need to ensure... (4 Replies)
Discussion started by: nbvcxzdz
4 Replies
Login or Register to Ask a Question