Inserting a String in a file header.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Inserting a String in a file header.
# 1  
Old 05-14-2008
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
# 2  
Old 05-14-2008
man sed
Code:
sed '1 s/$/FILE1\n/' file

# 3  
Old 05-14-2008
Can we include spaces in that sed command??

Thanks
hari
# 4  
Old 05-14-2008
Try it, and be amazed.
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 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

3. UNIX for Beginners Questions & Answers

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 <DOC> <DOCNO>3_September_2012</DOCNO> <TITLE> ... ... ... .... ... .. .. .. ... .. .. .... </TITLE> <TEXT> .... (1 Reply)
Discussion started by: imranrasheedamu
1 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. Shell Programming and Scripting

Inserting string in between field in comma separated file

Hello Mates, I have one txt file having commo seperated values. I have to insert string "FALSE" in 2nd field from the end. E.G SE18 6RN,,,,5439070,1786840,,1000002148671600,123434 Out put should be: SE18 6RN,,,,5439070,1786840,FALSE,1000002148671600,123434 Can some one help me to... (8 Replies)
Discussion started by: krsnadasa
8 Replies

7. 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

8. Shell Programming and Scripting

inserting a string to a text file

Hello Can somebody please help me with the following script? I'm trying to create a text file with 20 blank lines and then insert a string in line 2 but nothing is printed in the itxtfile. I can create the file with 20 blank lines but when I "tell" it to print something on the second line, it... (4 Replies)
Discussion started by: goude
4 Replies

9. 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

10. Shell Programming and Scripting

inserting a String in the file(s)

Hi, I'm a newbee to Unix shell scripting. I want to write a shell script that inserts a new String(name&value pair) into a file(s) at a particular place.I willl have to write one script which when executed should insert a new variable in all the files in that particular directory. Say for eg:... (4 Replies)
Discussion started by: 2tbee
4 Replies
Login or Register to Ask a Question