wtnabe (owner)

Revisions

gist: 125697 Download_button fork
public
Public Clone URL: git://gist.github.com/125697.git
Embed All Files: show embed
vcat.awk #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# Usage: vcat [-v ofs=<OFS>] <file1> [file2] ...
#
# Cannot specify field of file. Use cut command instead.
#
 
BEGIN {
    if ( ofs ) {
        OFS = ofs
    } else {
        OFS = "\t"
    }
 
    max_len = 0
    for ( i = 1; i < ARGC; i++ ) {
        filename = ARGV[i]
        cnt = 1
        while ( getline line < filename ) {
            content[i,cnt] = line
            if ( cnt > max_len ) {
                max_len = cnt
            }
            cnt++
        }
    }
 
    for ( cnt = 1; cnt <= max_len; cnt++ ) {
        $0 = ""
        for ( i = 1; i < ARGC; i++ ) {
            $i = content[i,cnt]
        }
        print
    }
}