Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
vertical 'cat' command known as a part of 'paste'
#
# 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment