Created
June 8, 2009 07:57
-
-
Save wtnabe/125697 to your computer and use it in GitHub Desktop.
vertical 'cat' command known as a part of 'paste'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment