(Video materials in preparation)
drawline : Draw lines
Usage : drawline <file>
drawline [+he] <file>
drawline [+he] <l> <file>
drawline [+he] <l>n <file>
drawline [+he] key=<key> <file>
Version : Wed Jun 18 16:44:37 JST 2014
Inserts a horizontal line between rows (records) in the specified
file. The line is drawn with "-" characters, the length of the line
is the same as the length of the first row.
If the file is omitted or specified as "-" this command will read
from standard input.
$ cat data
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
Only the line is output.
$ drawline data
-----------------------------------------------
Insert a line every 5th row.
$ drawline 5n data
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
-----------------------------------------------
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
03 New_Jersey 10 Newark 52 91 44 9 0
-----------------------------------------------
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
-----------------------------------------------
14 Pennsylvania 16 Hershey 45 21 24 39 03
Insert a line after rows 1,3,7 and 13.
Rows must be specified in order from small to large (1<3<7<13).
If you specify a negative number, the command counts backwards from
the last row.
0 specifies the first row, -0 specifies the last row.
$ drawline 1 3 7 13 data
01 Massachusetts 01 Boston 91 59 20 76 54
-----------------------------------------------
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
-----------------------------------------------
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
-----------------------------------------------
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
-----------------------------------------------
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
Insert a line whenever the <key> field's value changes.
For <key>, you can specify:
key=3
key=1/4
key=2@5
Insert a line in between different states (1st and 2nd fields).
$ drawline key=1/2 data
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
-----------------------------------------------
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
-----------------------------------------------
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
-----------------------------------------------
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
-----------------------------------------------
You can use the substr format for <key>.
key=2.1.5
key=4.2
(You cannot use this together with / and @.)
$ drawline key=1.1.1 data
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
-----------------------------------------------
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
Options
"+h" is used to add a double line "=" under the first row.
This is useful when the first row is a header row.
"+e" is used to add a double line "=" before the final row.
This is useful when the last row is a sum row.
If you want to use both options at the same time, specify "+he".
If you specify these options, the drawline command acts on the
data excluding the first and last rows.
$ cat data2
No State No City A B C D E
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
@@ @@@@@@@@ @@ @@@@@@@@@@ 421 272 194 255 231
$ drawline +he key=1/2 data2
No State No City A B C D E
===============================================
01 Massachusetts 01 Boston 91 59 20 76 54
01 Massachusetts 02 Worcester 46 39 8 5 21
01 Massachusetts 03 Springfield 82 0 23 84 10
-----------------------------------------------
02 New_York 04 Manhattan 30 50 71 36 30
02 New_York 05 Brooklyn 78 13 44 28 51
02 New_York 06 Queens 58 71 20 10 6
02 New_York 07 Bronx 39 22 13 76 08
02 New_York 08 Albany 82 79 16 21 80
02 New_York 09 Buffalo 50 2 33 15 62
-----------------------------------------------
03 New_Jersey 10 Newark 52 91 44 9 0
03 New_Jersey 11 Trenton 60 89 33 18 6
03 New_Jersey 12 Moorestown 95 60 35 93 76
-----------------------------------------------
14 Pennsylvania 13 Philadelphia 92 56 83 96 75
14 Pennsylvania 14 Pittsburgh 30 12 32 44 19
14 Pennsylvania 15 Lancaster 48 66 23 71 24
14 Pennsylvania 16 Hershey 45 21 24 39 03
===============================================
@@ @@@@@@@@ @@ @@@@@@@@@@ 421 272 194 255 231