add header in each file of folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting add header in each file of folder
# 1  
Old 09-07-2012
Bug add header in each file of folder

My files location

Dir=/pp/Output/Test/

I have 100 .txt files on above location.

I want add header "pt all" on each file.

Sample Text file

Code:
Hi
Kalol
Jt all
q

Output i want

Code:
lt all
Kalol
Jt all
q

# 2  
Old 09-07-2012
Code:
sed -i '1i pt all' *.txt

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 09-07-2012
To Remove first header line

Code:
for i in /pp/Output/Test/*.txt
do
sed '1 c\pt all'  $i
done


To add Line before fist line is - Just replace c with i

Code:
for i in /pp/Output/Test/*.txt
do
sed '1 i\pt all'  $i
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split and add header and trailer from input file

I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file Also is it possible to output the TOM and PAT records in the same output file ? I need the output file names same as xyz_pattern_Datetimestamp.txt ... (23 Replies)
Discussion started by: techedipro
23 Replies

2. UNIX for Dummies Questions & Answers

How to add a header to a tab delimited .txt file?

Hi, I have a tab delimited document with 18 columns. My file looks like: comp1000201_c0_seq1 comp1000201_c0 337 183.51 0.00 0.00 0.00 0.00 ---NA--- 337 0 0 - comp1000297_c0_seq1 comp1000297_c0 612 458.50 ... (1 Reply)
Discussion started by: alisrpp
1 Replies

3. Shell Programming and Scripting

Add column header and row header

Hi, I have an input like this 1 2 3 4 2 3 4 5 4 5 6 7 I would like to count the no. of columns and print a header with a prefix "Col". I would also like to count the no. of rows and print as first column with each line number with a prefix "Row" So, my output would be ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

5. Shell Programming and Scripting

Add header to a .csv file

Hi, I am trying to add a header record to all the .csv files in a directory. I am using the below sed commnad sed -i '1 i \abc,sam,xyz,tip,pep,rip' xyz.csv but this is not adding the header and I am not getting any error,pls tell me if any thing is wrong in the code. Thanks, Shruthi (2 Replies)
Discussion started by: shruthidwh
2 Replies

6. Shell Programming and Scripting

How to update copyright header on a folder

Hi, I have multiple shell scripts in diffrent folders on server. Most of them contain copyright information like on the third line * Copyright © 2004, 2005, My Inc. All rights reserved. I need to change these headers to * Copyright © 2003, 2009, My Inc. All rights reserved. ... (2 Replies)
Discussion started by: neeto
2 Replies

7. UNIX for Dummies Questions & Answers

Add a header to a sort file instruction

Hello, I have a header which I have to add to a sorted file, however if I use cat header sortedfile > newfile, the operation takes 2 minutes as the sorted file is over 400mb. I have noticed that when I sort the 400mb unsorted file, this only takes 14 seconds to create the output. As... (2 Replies)
Discussion started by: clarcombe
2 Replies

8. Shell Programming and Scripting

How can I add a header to a csv file

I have a csv file which has no header. the file has 15 fields and needs to go out with a header of 8 fields. The header content needs to have some variables and some fixed that i have set up: variable header fields OUTFILE_YEAR=`date '+%y'` DATE=`date '+%d%m%y'` TIME=`date '+%H:%M:%S'`... (6 Replies)
Discussion started by: Pablo_beezo
6 Replies

9. Shell Programming and Scripting

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

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? (7 Replies)
Discussion started by: ashish4422
7 Replies

10. 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
Login or Register to Ask a Question