Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Created June 8, 2009 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtnabe/125697 to your computer and use it in GitHub Desktop.
Save wtnabe/125697 to your computer and use it in GitHub Desktop.
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