File: align-columns

package info (click to toggle)
ncbi-entrez-direct 19.0.20230216%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,316 kB
  • sloc: sh: 14,524; xml: 1,297; perl: 602; makefile: 135; awk: 32; python: 26
file content (63 lines) | stat: -rwxr-xr-x 1,407 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh

# Public domain notice for all NCBI EDirect scripts is located at:
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice

# inspired by Steve Kinzler's align script - see http://kinzler.com/me/align/

# requires tab-delimited input, output aligned by padding with spaces

# -a    Column alignment codes:
#
#         l left
#         c center
#         r right
#         n numeric (align on decimal point)
#         N numeric (decimal parts zero-padded)
#
# -g    Spacing between columns
# -h    Indent before columns

if [ $# -gt 0 ]
then
  case "$1" in
    -version )
      version=$( einfo -version )
      echo "$version"
      exit 0
      ;;
    -help | --help | help )
      version=$( einfo -version )
      echo "align-columns $version"
      cat << EOF

  -a    Column alignment letters, with last repeated as needed:

          l  left
          c  center
          r  right
          n  numeric aligned on decimal point
          N  numeric with decimal parts zero-padded
          z  zero-pad leading integers
          m  commas to group by 3 digits
          M  commas plus zero-pad decimals

  -g    Spacing between columns
  -h    Indent before columns
  -w    Minimum column width

EOF
      exit 0
      ;;
    * )
      break
      ;;
  esac
fi

if [ "$#" -gt 0 ] && [ "$*" = "-" ]
then
  transmute -align -h 2 -g 4 -a l
else
  transmute -align "$@"
fi