Revision 1534
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/row | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 |
# Gets a row of a spreadsheet. Designed for row #s in map error messages. |
|
2 |
# Gets row(s) of a spreadsheet. Designed for row #s in map error messages. |
|
3 |
# Warning: Does *not* handle embedded newlines. |
|
3 | 4 |
|
4 | 5 |
if ! test "$#" -eq 1; then |
5 |
echo "Usage: $0 row_num (zero-based, excluding header) <sheet >row_out" |
|
6 |
echo "Usage: env [n=...] $0 row_num (zero-based, excluding header) <sheet \ |
|
7 |
>row_out" |
|
6 | 8 |
exit 2 |
7 | 9 |
fi |
8 | 10 |
|
11 |
test -n "$n" || n=1 |
|
12 |
|
|
9 | 13 |
# Add 1 for header row and 1 for tail's 1-based row #s |
10 |
tail -n +"$(($1+2))"|head -1 |
|
14 |
tail -n +"$(($1+2))"|head -"$n" |
Also available in: Unified diff
row: Support getting multiple rows. Document that does not handle embedded newlines.