Split large file and add header and footer to each small files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Split large file and add header and footer to each small files
# 8  
Old 07-07-2008
I have a similar task I want to perform, however, I don't need a footer and my header will be the same every time. Also, my header is multiple lines long. I imagine I would just write:
Code:
 $ split -d -l 3 temp.txt file && for X in file*; do { echo "header"; cat $X; } > $X.txt; done

I don't know how to deal with the line breaks though. Can anyone help?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Split large file into 24 small files on one hour basis

I Have a large file with 24hrs log in the below format.i need to split the large file in to 24 small files on one hour based.i.e ex:from 09:55 to 10:55,10:55-11:55 can any one help me on this.! ... (20 Replies)
Discussion started by: Raghuram717
20 Replies

2. Shell Programming and Scripting

Split large xml into mutiple files and with header and footer in file

Split large xml into mutiple files and with header and footer in file tried below it splits unevenly and also i need help in adding header and footer command : csplit -s -k -f my_XML_split.xml extrfile.xml "/<Document>/" {1} sample xml <?xml version="1.0" encoding="UTF-8"?><Recipient>... (36 Replies)
Discussion started by: karthik
36 Replies

3. Shell Programming and Scripting

Breaking large file into small files

Dear all, I have huge txt file with the input files for some setup_code. However for running my setup_code, I require txt files with maximum of 1000 input files Please help me in suggesting way to break down this big txt file to small txt file of 1000 entries only. thanks and Greetings, Emily (12 Replies)
Discussion started by: emily
12 Replies

4. Shell Programming and Scripting

Split a large array into small chunks

Hi, I need to split a large array "@sharedArray" into 10 small arrays. The arrays should be like @sharedArray1,@sharedArray2,@sharedArray3...so on.. Can anyone help me with the logic to do so :(:confused: (6 Replies)
Discussion started by: rkrish
6 Replies

5. Shell Programming and Scripting

Add header and footer with record count in footer

This is my file(Target.txt) name|age|locaction abc|23|del xyz|24|mum jkl|25|kol The file should be like this 1|03252012 1|name|age|location 2|abc|23|del 2|xyz|24|mum 2|jkl|25|kol 2|kkk|26|hyd 3|4 Column 1 is row indicator for row 1 and 2, column indicator is 1,for data rows... (1 Reply)
Discussion started by: itsranjan
1 Replies

6. Shell Programming and Scripting

How to add header and footer?

Hi, Guys, I want add header and footer in a file. I can add footer using following command: echo "Footer" >>file. I don't know how to add header. Thanks in advance (4 Replies)
Discussion started by: ken002
4 Replies

7. Shell Programming and Scripting

script to splite large file to number of small files

Dear All, Could you please help me to split a file contain around 240,000,000 line to 4 files all equally likely , note that we need to maintain that the end of each file should started by start flage (MSISDN) and ended by end flag (End), also the number of the line between the... (10 Replies)
Discussion started by: ahmed.gad
10 Replies

8. Shell Programming and Scripting

Split a file into 16 small files

Hi I want to split a file that has 'n' number of records into 16 small files. Can some one suggest me how to do this using Unix script? Thanks rrkk (10 Replies)
Discussion started by: rrkks
10 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

Splitting large file into small files

Hi, I need to split a large file into small files based on a string. At different palces in the large I have the string ^Job. I need to split the file into different files starting from ^Job to the last character before the next ^Job. Also all the small files should be automatically named.... (4 Replies)
Discussion started by: dncs
4 Replies
Login or Register to Ask a Question
SGML2HTML(1)						      General Commands Manual						      SGML2HTML(1)

NAME
sgml2html - create HTML output from a LinuxDoc DTD SGML source file SYNOPSIS
sgml2html [generic-option...] [--split 0|1|2 ] [--toc 0|1|2 ] [--dosnames] [--imagebuttons] file[.sgml] DESCRIPTION
sgml2html is an old and obsoleted form of the html converter command of LinuxDoc-Tools. It is recommended to switch the new form linuxdoc -B html now. This converts a LinuxDoc DTD SGML source file to HTML output. Output will appear in the top level file file.html and file- n.html for each section, where file is the name of the SGML source file and n is the section name. The attribute/value pair "output=html" is set for conditionals. OPTIONS
sgml2html accepts all the generic options described in linuxdoc(1), and the following specific options: --split, -s What level to split source documents. 0 = don't split, 1 = split by major sections, 2 = split by subsections. --toc, -T What level to generate toc. 0 = don't generate toc at all, 1 = includes major sections(/chapters/parts), 2 = includes subsections. --dosnames, -h Use ".htm" rather than ".html" as the extension of --imagebuttons, -I Use the "next", "previous", and "contents" arrow image icons included in /usr/share/linuxdoc-tools as navigation buttons. --footer, -F Use the specified file as the footer in each resulted html file. Default footer is just plain </BODY> </HTML> --header, -H Use the specified file as the top part of the header in each resulted html file. Note this is not the full part of the header. (i.e. the title and the links (next,previous,contents) in the default header are retained. Default is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> file The SGML source file, named either file or file.sgml. FILES
Many files and executables in /usr/share/linuxdoc-tools and /usr/bin are used. BUGS
None known. AUTHOR
Originally written by Greg Hankins <greg.hankins@cc.gatech.edu>, and Cees de Groot <cg@cdegroot.com> for SGML-Tools (v1). Currently main- tained by Taketoshi Sano <sano@debian.org> for Linuxdoc-Tools. SEE ALSO
linuxdoc(1), sgml2info(1), sgml2latex(1), sgml2lyx(1), sgml2rtf(1), sgml2txt(1), sgmlcheck(1). 16 May 2000 SGML2HTML(1)