Inserting Header at different position in a file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Inserting Header at different position in a file
# 1  
Old 06-22-2016
Inserting Header at different position in a file

I would like to hear your directions on how to Insert theses tag </TITLE> and <TEXT> at a given position in 1000 of text files.

My Files look like as

samplefile1.txt
Code:
<DOC>
<DOCNO>3_September_2012</DOCNO>
<TITLE>
... ... ... .... ... .. .. .. ... .. .. .... 
</TITLE>
<TEXT>
. .............. ... .... ... ... ... .... ...... ... ... .. .......  .. .... ... ........ ... .. ... .. .. .. .... .. ... ... ..... .. ....  ...... .... ..... ..... ... ...... .. ..... ... .. ....... .. .... .....  ..... .... .. ... ... .. ..... ... ... ...... .. .... .... ... .....  .... ... .... .. ... .... .. .... .. .. ..... .. ..... ... .....  ........ .... ..    ..... ... ... ... ... ...... ... ... .. .... ....... ..  ... .. ...... ..    ... ..... ... .... .... .. .. .... ....... .. .....  .... .... ... .. ... .. .... ... .. .. ... ... .... ... .. .... ... ...  .. .... ... .... .... .. .

</TEXT>
</DOC>

samplefile2.txt
Code:
<DOC>
<DOCNO>1_March_2014</DOCNO>
<TITLE>
........ .. ..... ... .. ....... ..... .. ...... ..
.. .... ... .. .........
.. .. .... .... .. ..... ..
</TITLE>
<TEXT>
..... ... .... .. .... .. .. ..... ... ...... .... ...... ... .. ..  ... ...... .. ..... ...... ... .... .. .. .... .... .. .... ... ... ..  ..... .. .... .... ..... ..... .... ... .. .. .. .... ... ... ..... ...  .... .. .... ... .. ... .. .... ........... . .. ..... . . ...... .....  ... .... .... . ..... .... .... ..
.... ..... ......... ........ ... ..... .. ...... ........ .. .... ....  .... ......... .. .......... .. .... ..... .... .. ..... .......... ....  ..... .... ..... ... .... .. ....... .. ..... ...... .... .. ..... ...  .... .. ..... .... ..... ... ..... .. ... . ... ... .... .. ......  ...... .. .... ..... ..... .. ... .... .. .. .... ...... ..... .......
</TEXT>
</DOC>

samplefile3.txt
Code:
<DOC>
<DOCNO>10_September_2012</DOCNO>
<TITLE>
... .. .. ...... ... ... .... ..... ... .. . .. .... .. .... .. .. ... ..
 ......... ... .. ..... .... .... .. ... .. ...... .. .. ..... .. ... ...
</TITLE>
<TEXT>
..... ......... ... .... ..... ... .. ..... .... .... .. ... .. ......  .. .. ... .. .. ... ... .. ... .... ... .. .. .. ...... .. .. ..... ...  .. ... .. ....... .... ..... .. ... ... ... ... .. ... ... .... .. .. ..  ... ... .. .. ... ...... .... ..... .... .. ... .. ..... .. ... ... ..  .. ..... ..... .. .... .. ... . ..... .. ...... .. .... .... .....  ........ .. ..... ..... .. ..... ... ...... .. ... .... .. .......  ........ ... .... .. ...... ..... .... .... ..... .... .... .... .....  .... .. ....... ..... .. ... .. .... . ..... ... .... ... .... ....  ..... .. ..... .... ... ... ... ... .. ... .... ......... ... .. .. ..  .. .. .... ... </TEXT>
</DOC>




Moderator's Comments:
Mod Comment AGAIN: Please comply with forum rules - here: (9) English only! Not complying may result in infraction points given or even punitive measures taken.
Text samples moderated.

Last edited by RudiC; 06-23-2016 at 05:32 AM.. Reason: Change B tags to ICODE tags; add CODE and ICODE tags.
# 2  
Old 06-22-2016
Please explain why the suggestions in posts #8 and #9 your earlier thread: Insert Text after one, two, three lines & so on.. did not already answer this question???
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. Shell Programming and Scripting

Inserting value at a particular position without changing the position of other characters

Hi All, I wanted a sed/awk command to add a value/character on a particular position without disturbing the position of other characters. I have file a.txt OL 10031 Day Black Midi Good Value P01 P07 OL 10031 Day Black Short Good Value P01 P07 I want to get the output as... (2 Replies)
Discussion started by: rahulsk
2 Replies

3. Shell Programming and Scripting

Inserting a header with special character

Hi, I am trying to insert header row with a special character delimiter with Unicode u0109 into a file with ‘echo’, header looks like below echo –e “header1\u0109header\u0109header3\u0109header4” It just inserting as it is in the quotes but not the special character, Please suggest if am... (2 Replies)
Discussion started by: oom
2 Replies

4. Shell Programming and Scripting

Inserting Header to another file

Need your help in appending header(file1 contains header ) to my file2. I am using KSH AIX OS. I know how to do with taking temporary files. cat file1 >temp cat file2 >>temp mv temp file2 Is there way to append directly to a file in ksh. I don't find Sed -i option on my... (10 Replies)
Discussion started by: gvkumar25
10 Replies

5. Shell Programming and Scripting

Inserting header after every nth line

Hi Experts, I have a file which contain hundreds of records/lines. I want to insert the below header in the file after every 60 lines. #Header FirstName LastName Address --------- ---------- --------- Let say I saved the... (6 Replies)
Discussion started by: brichigo
6 Replies

6. Ubuntu

Inserting a header with column number to a 1.6 GB file with special spacing

Hi; I've been searching posts to find a solution to what I'm trying to do, but I've have NOT found anything yet. I have a file (file1) with 300K columns and 1411 rows, the columns don't have a column no. header (No header at all) and I'm trying to fetch the information from specific columns.... (3 Replies)
Discussion started by: sogi
3 Replies

7. Shell Programming and Scripting

Inserting Header and footer

Hi All, I have several txt files i need to enter specific header and footer (both are separate) to all these files how can i do this? plz help.. Regards, Raghav (4 Replies)
Discussion started by: digitalrg
4 Replies

8. Shell Programming and Scripting

Inserting a String in a file header.

Dear all, I have a file created in the name sample.txt in UNIX with header and footer. How to insert a required string (for example "FILE1") in the header part after the file has been created. What kind of command can i use to do the same. Thanks in advance Hari (3 Replies)
Discussion started by: Hari123
3 Replies

9. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies

10. UNIX for Dummies Questions & Answers

Inserting a delimiter after certain charater position

Hi, I have a string : - ICFFHASMTAAMPFINCL22082006000002548789632 and i want to add delimiter after certain charater position through a script, eg. ICFFH,ASMTAAMPF,INCL,22082006,000002548789632. I have tried and am able to achieve it through cut-paste. But i don't want to use cut paste as it... (6 Replies)
Discussion started by: divz
6 Replies
Login or Register to Ask a Question