-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathshowcol
executable file
·38 lines (34 loc) · 1007 Bytes
/
showcol
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
36
37
#!/usr/bin/awk -f
#
# Copyright (c) 2016 Douglas G. Scofield, Uppsala University
#
# This code is covered by the Gnu GPLv2, please see LICENSE.
# Bugs and suggestions to https://github.com/douglasgscofield/tinyutils/issues.
#
# Print the contents of each column prefixed by the column number
#
# CHANGELOG
# 2016-02-16 : do not print header and comment lines as they are skipped
# 2016-02-11 : create the script
BEGIN {
# parameters
FS="\t"; # default to tab column separators
header = 0; # does the input have a header? if so how many lines?
skip_comment = 1; # skip '#' lines on input
lines = 1; # the number of lines to do this for
sep = ":";
}
{
if (NR <= header) { next; }
if (skip_comment && $0 ~ /^#/) { next; }
if (lines > 0) {
for (col = 1; col <= NF; ++col) {
$(col) = col sep $(col);
}
OFS = FS;
print;
--lines;
}
}