| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Public domain notice for all NCBI EDirect scripts is located at: |
| 4 |
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice |
| 5 |
|
| 6 |
# inspired by Steve Kinzler's align script - see http://kinzler.com/me/align/ |
| 7 |
|
| 8 |
# requires tab-delimited input, output aligned by padding with spaces |
| 9 |
|
| 10 |
if [ $# -gt 0 ] |
| 11 |
then |
| 12 |
case "$1" in |
| 13 |
-version ) |
| 14 |
version=$( einfo -version ) |
| 15 |
echo "$version" |
| 16 |
exit 0 |
| 17 |
;; |
| 18 |
-help | --help | help ) |
| 19 |
version=$( einfo -version ) |
| 20 |
echo "align-columns $version" |
| 21 |
cat << EOF |
| 22 |
|
| 23 |
-a Column alignment letters, with last repeated as needed: |
| 24 |
|
| 25 |
l left |
| 26 |
c center |
| 27 |
r right |
| 28 |
n numeric aligned on decimal point |
| 29 |
N numeric with decimal parts zero-padded |
| 30 |
z zero-pad leading integers |
| 31 |
m commas to group by 3 digits |
| 32 |
M commas plus zero-pad decimals |
| 33 |
w just print column widths |
| 34 |
|
| 35 |
-g Spacing between columns |
| 36 |
-h Indent before columns |
| 37 |
-w Minimum column width |
| 38 |
|
| 39 |
EOF |
| 40 |
exit 0 |
| 41 |
;; |
| 42 |
* ) |
| 43 |
break |
| 44 |
;; |
| 45 |
esac |
| 46 |
fi |
| 47 |
|
| 48 |
if [ "$#" -gt 0 ] && [ "$*" = "-" ] |
| 49 |
then |
| 50 |
transmute -align -h 2 -g 4 -a l |
| 51 |
else |
| 52 |
transmute -align "$@" |
| 53 |
fi |