]> git.mxchange.org Git - flightgear.git/blob - scripts/atis/words_per_line.sh
Allow using the system version of flite and the HTS engine
[flightgear.git] / scripts / atis / words_per_line.sh
1 #! /bin/bash
2
3 ## 
4 ## 
5
6 if test "x$1" = "x-h" ; then
7   1>&2 echo "Usage: "
8   1>&2 echo "   $0 [filename]"
9   1>&2 echo "Read words from input, treating all whitespace like,"
10   1>&2 echo "and write exactly N words per line on output."
11   1>&2 echo "Options:  "
12   1>&2 echo "   -n [N]  specify N (default: 1)"
13   1>&2 echo "   filename = '-' or '' ==> read from standard input"
14   exit 1
15 fi
16
17 : ${wordmax:=1}
18 files=""
19
20
21 while 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 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