Removing Header from files before Concatenation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing Header from files before Concatenation
# 1  
Old 04-13-2010
Data Removing Header from files before Concatenation

I need to concatenate the files of same type but with different names that conatin header. Before conactenating its mandatory to remove the header from the files ..

and after concatenation the output file should contain header too.


how to do it...


thanks in advance.
# 2  
Old 04-13-2010
Can you give some sample input data and your expected sample results?
# 3  
Old 04-13-2010
Concatenate the first file simply...

Code:
cat file1 > out-file


Concatenate the remaining files, by ignoring first N lines..

Code:
head -n 2 file2 >> out-file

# 4  
Old 04-13-2010
I think Geek's code won't work while appending 2nd file. You can try this. My assumption is your header is first line.
Code:
cat file1 > out-file
sed -e '1d' file2 >> out-file

-Nithin
# 5  
Old 04-13-2010
Try this also:
Code:
cat file1 > out-file
sed '2,$!d' file2 >> out-file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenation of files with same naming patterns dynamically

Since my last threads were closed on account of spamming, keeping just this one opened! Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR"... (5 Replies)
Discussion started by: Jesshelle David
5 Replies

2. UNIX for Advanced & Expert Users

Removing Header and Trailer record of a EBCDIC file

I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long. Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies

3. Shell Programming and Scripting

Removing header or footer from file

Hi Every one, what is the coomand to remove header or footer from a file. Please help me by providing command/syntax to remove header/footer from unix. Thanks in advance for all your support. (5 Replies)
Discussion started by: sridhardwh
5 Replies

4. Shell Programming and Scripting

Removing header and footer

I have two files which are getting sent to a UNIX server in order to be bcp'd into a database. The bcp is failing because there's a header and footer row on the file which give the date of the file and the number of rows in it. That's because the file is also being used for another process, so we... (1 Reply)
Discussion started by: Tom Sawyer
1 Replies

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

6. Shell Programming and Scripting

Concatenation of a large number of files

Hellow i have a large number of files that i want to concatenate to one. these files start with the word 'VOICE_' for example VOICE_0000000000 VOICE_1223o23u0 VOICE_934934927349 I use the following code: cat /ODS/prepaid/CDR_FLOW/MEDIATION/VOICE_* >> /ODS/prepaid/CDR_FLOW/WORK/VOICE ... (10 Replies)
Discussion started by: chriss_58
10 Replies

7. Shell Programming and Scripting

Removing Header & Trailer from a file

Hi All, I am karthik. I am new to this forum. I have one requirement. I have a file with header and footer. Header may be like HDR0001 or FILE20090110 (Assume it is unknown so far, but i am sure there is a header in the file) likewise file has the trailer too. I just... (7 Replies)
Discussion started by: karthi_gana
7 Replies

8. UNIX for Dummies Questions & Answers

Concatenation of multiple files with wildcard

I have the following snippet to concatenate about a hundred csv-files: for file in *csv; do cat $file >> newfile; done This line works, but before I was experimenting with the following line, which is more intuitive and is a tad more robust: for file in *.csv; do cat $file >> newfile; done Can... (2 Replies)
Discussion started by: figaro
2 Replies

9. Shell Programming and Scripting

rowwise concatenation of files

Hi , I am having a file 1n.txt - cat 1n.txt gives get_next_sp_fixing_mod_ref_no, get_next_sp_tran_ref_no, cat 2n.txt - boxer1.cpp boxer2.cpp I want a file resn.txt which has - get_next_sp_fixing_mod_ref_no,boxer1.cpp get_next_sp_tran_ref_no,boxer2.cpp How can i do that ? Its... (3 Replies)
Discussion started by: sid1582
3 Replies

10. UNIX for Advanced & Expert Users

Faster Concatenation of files

Dear All I am using cat command for concatenating multiple files. Some time i also use append command when there are few files. Is there faster way of concatenating multiple files(60 to 70 files) each of 156 MB or less/more.:) Thanx (1 Reply)
Discussion started by: tkbharani
1 Replies
Login or Register to Ask a Question