| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | ## |
| 4 | ## |
| 5 | |
| 6 | if testscip-shell system . . test. "x$1" = "x-h" ; then |
| 7 | 1>&2 echoscip-shell system . . echo. "Usage: " |
| 8 | 1>&2 echoscip-shell system . . echo. " $0 [filename]" |
| 9 | 1>&2 echoscip-shell system . . echo. "Read words from input, treating all whitespace like," |
| 10 | 1>&2 echoscip-shell system . . echo. "and write exactly N words per line on output." |
| 11 | 1>&2 echoscip-shell system . . echo. "Options: " |
| 12 | 1>&2 echoscip-shell system . . echo. " -n [N] specify N (default: 1)" |
| 13 | 1>&2 echoscip-shell system . . echo. " filename = '-' or '' ==> read from standard input" |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | : ${wordmax:=1} |
| 18 | files="" |
| 19 | |
| 20 | |
| 21 | while testscip-shell system . . test. -n "$*" ; do |
| 22 | this=$1 ; shift |
| 23 | case $this in |
| 24 | -n) wordmax=$1 ; shift |
| 25 | ;; |
| 26 | *) files="$files $this" |
| 27 | ;; |
| 28 | esac |
| 29 | done |
| 30 | |
| 31 | |
| 32 | awkscip-shell system . . awk. '{ |
| 33 | for (ii = 1; ii <=NF; ii++) { |
| 34 | printf ("%s", $ii); |
| 35 | words++; |
| 36 | if (words >= wordmax) { |
| 37 | print ""; |
| 38 | words = 0; |
| 39 | } else { |
| 40 | printf (" "); |
| 41 | } |
| 42 | } |
| 43 | }' wordmax=$wordmax $files |