1 |
1480
|
aaronmk
|
#!/bin/bash
|
2 |
1534
|
aaronmk
|
# Gets row(s) of a spreadsheet. Designed for row #s in map error messages.
|
3 |
|
|
# Warning: Does *not* handle embedded newlines.
|
4 |
1480
|
aaronmk
|
|
5 |
1481
|
aaronmk
|
if ! test "$#" -eq 1; then
|
6 |
1946
|
aaronmk
|
echo "Usage: env [n=...] $0 row_num <sheet >row_out
|
7 |
3405
|
aaronmk
|
Note: Row #s start with 1 after the header (which is row 0)"|fold -s >&2
|
8 |
1480
|
aaronmk
|
exit 2
|
9 |
|
|
fi
|
10 |
|
|
|
11 |
1534
|
aaronmk
|
test -n "$n" || n=1
|
12 |
|
|
|
13 |
1946
|
aaronmk
|
# Add 1 for header row (tail has 1-based row #s, so don't need to add 1 more)
|
14 |
|
|
tail -n +"$(($1+1))"|head -"$n"
|