multiple file input 
Author Message
 multiple file input

Hi there,

Here is my problem:

I have 2 files:

file1:
1
3
5
7

file2:
2
4
6
8

How can I use awk to join them together so that the output is like:

1
2
3
4
5
6
7
8

Thanks for your answer.



Tue, 22 Feb 2000 03:00:00 GMT  
 multiple file input

How about this:

#
#   MERGE.AWK
#
#   Invoke as follows:
#
#       gawk -f MERGE.AWK file1 file2
#

BEGIN {

    while ( ! end_of_file[1] || ! end_of_file[2] )
    {
        if ( ! end_of_file[1] )
        {
            if ( getline line < ARGV[1] > 0 )
                print line
            else
                end_of_file[1] = 1
        }

        if ( ! end_of_file[2] )
        {
            if ( getline line < ARGV[2] > 0 )
                print line
            else
                end_of_file[2] = 1
        }
    }

    exit(0)

Quote:
}

--
Best regards,
 _ __                      _    ,   _ _ _
' )  )     /         _/_  ' )  /   ' ) ) )
 /--' ____/___/> __  /     /--/     / / / __,_  __  o _   ______
/  \_(_) /_) (__/ (_<__   /  ( o   / ' (_(_) (_/ (_<_/_)_(_) / <_

Robert H. Morrison                      Tel:    +49 721 9628 167
Software Development, Basis Team        FAX:    +49 721 9628 261



Quote:
> Hi there,

> Here is my problem:

> I have 2 files:

> file1:
> 1
> 3
> 5
> 7

> file2:
> 2
> 4
> 6
> 8

> How can I use awk to join them together so that the output is like:

> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8

> Thanks for your answer.



Tue, 22 Feb 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TK/Tix MULTIPLE file input widget ???

2. Help!! Multiple file input with output to one or more files

3. Help on opening multiple input files(test vector files)

4. Multiple input files execution

5. Processing multiple input files

6. Multiple input files to awk

7. multiple input files record-wise?

8. Multiple Input Files

9. In trouble with multiple input files.

10. Multiple input files in awk?

11. Open multiple files based on user input?

12. Sequential File Update w/ Multiple Input Records

 

 
Powered by phpBB® Forum Software