|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
merge text files
Hello.
Could you please help to know the command to merge multiple text files into one? I am thinking to use: cat f1.txt f2.txt f3.txt > f4.txt Is it okay to use cat command for same purpose - Or could there be any disadvantage in using it? Thank you |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
It is ok; you could just try it out and check the file afterwards. If it looks ok, cat and the redirection must have done a good job.
Since this is nothing special to AIX think about posting such kind of question into one of the more appropriate forums next time please. No offense, but since this is a very basic question UNIX for Dummies Questions & Answers - The UNIX and Linux Forums would be a good choice for it next time. If it goes deeper into shell scripting etc. you can also post in Shell Programming and Scripting - The UNIX and Linux Forums UNIX for Advanced & Expert Users - The UNIX and Linux Forums |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Quote:
Regards |
|
#4
|
|||
|
|||
|
Hello - Thanks for your reply.
Now consider I have a common header 'HEADER' and trailer 'TRAILER' in all the files and I want to have their header , trailer only once in the concatenated output file. Please advice how could that be done? Thank you |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
If you have the 'HEADER' at the first line and 'TRAILER' at the last line in all your files you can delete the those lines after merging the files with: Code:
awk -v var=`wc -l < file` 'NR>1 && /HEADER/ || NR<var && /TRAILER/{next}{print}' file > newfileFirst we use a variable var wich is the number of the last line (wc -l < file). Now we print every line except the line with HEADER if it isn't the first line and the line with TRAILER if it isn't the last line. Regards |
| Sponsored Links | ||
|
![]() |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| merge two text files of different size on common index | LMHmedchem | Shell Programming and Scripting | 8 | 05-01-2011 08:45 PM |
| Have several text files and want to merge into a single | richsark | Shell Programming and Scripting | 4 | 03-02-2009 03:11 PM |
| Merge 2 text files to one text file side by side | ahinkebein | Shell Programming and Scripting | 15 | 02-04-2009 10:28 AM |
| Merge text files while combining the multiple header/trailer records into one each. | oordonez | Shell Programming and Scripting | 4 | 11-17-2008 10:06 PM |
| Is there any non graphical tool that make selective merge between text files? | umen | UNIX for Dummies Questions & Answers | 3 | 08-25-2005 02:22 AM |
|
|