ORDINAL(1) | General Commands Manual | ORDINAL(1) |

`ordinal`

— convert
cardinal numbers to ordinal numbers

`ordinal` |
[`-p` indicies ...]
[file ...] |

The `ordinal`

utility converts cardinal
numbers into ordinal numbers. Input is read from the files provided as
command-line arguments, or the standard input if none are supplied.
Additionally, the special filename ‘-’ can be provided to
refer to the standard input.

When processing input, any text that does not constitue a number
(any sequence of the digits 0–9) is simply printed to the standard
output verbatim. Numbers on the other hand are suffixed as per the rules of
the English language (21 becomes ‘21st’, 57 becomes
‘57th’, and so on). The default behavior is to suffix all
numbers with either ‘st’, ‘nd’,
‘rd’, or ‘th’ — although this behavior
can be modified with the `-p`

flag.

The options are as follows:

`-p`

,`--positions`

=`indicies`- Only convert the cardinal numbers in the positions specified by the
comma-separated list
`indicies`. For example, if`indicies`is ‘1,3,5’, then only the 1st, 3rd, and 5th numbers on each line of input will be converted.The provided list of indicies must only contain positive integers, and no whitespace.

The `ordinal`

utility exits 0 on
success, and >0 if an error occurs.

Get the ordinal numbers 1–25:

`$ seq 25 | ordinal`

Get the date, turning the day of the month into an ordinal whiel the year remains a cardinal (e.g. ‘29th of September, 2003’):

```
$ date +'%d of %B, %Y' | ordinal -p
1
```

Thomas Voss <[email protected]>

October 4, 2023 | MangoOS |