![]() |
|
#1
|
|||
|
|||
appending with AWKHi all,
I have two files called INPUT1 and INPUT2 and i am trying to append the values of INPUT1 to INPUT2 using AWK. The INPUT1 file will always has a single field and the INPUT2 file has 3 fields but both files will have same number of records always. Following is the format of the two files, INPUT1: PROD DEV QA INPUT2: DB1,PRIMARY,NY DB2,SECONDARY,CA DB3,TERTIARY,MN Now, the issue i am working on is to append the values of INPUT1 to the file INPUT2 using awk. So, after appending the output should look like following, DB1,PRIMARY,NY,PROD DB2,SECONDARY,CA,DEV DB3,TERTIARY,MN,QA i.e., the first record of INPUT1 should be appended to the 1st record (last field) of INPUT2 and so on...... As i said the number of records in each file will be same. So, each record in file1 should be appended to corresponding record in file2. Any other way of achieving this without using AWK? Any suggestions? Thanks, Harris. |
|||
|
#2
|
|||
|
|||
Re: appending with AWKQuote:
Just read one file into an array, then append an array element to each line of the second file: Here is file comb.awk: Code:
File INPUT1: Code:
File INPUT2: Code:
Command and output: Code:
Quote:
Do you want it with AWK or not? Make up my mind! If you have the GNU text utility paste installed (as, I think, most Linux distros do), then: Code:
Regards, Dave Last edited by davekw7x : 12-Sep-2007 at 17:36.
|
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Appending file | baard | C++ Forum | 4 | 09-May-2007 06:23 |
| Problem inserting (appending) in the middle of text file | rajeev nair | C++ Forum | 3 | 17-Apr-2007 00:55 |
| Repeated appending to strings | anders | C Programming Language | 6 | 09-Mar-2007 13:55 |
| txt appending | DesperateCry | C Programming Language | 5 | 26-May-2005 05:18 |
| [Tutorial] Standard I/O | aaroncohn | C Programming Language | 20 | 27-Feb-2004 21:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The