---
name: "tv_sort"
section: "1p"
platform: "linux"
package: "xmltv-util"
version: "1.4.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/tv_sort"
---

# tv\_sort(1p)

Sort XMLTV listings files by date, and add stop times.

## NAME

tv\_sort - Sort XMLTV listings files by date, and add stop times.

## SYNOPSIS

tv\_sort \[--help\] \[--by-channel\] \[--output FILE\] \[FILE...\]

## DESCRIPTION

Read XMLTV data and write out the same data sorted in date order. Where stop times of programmes are missing, guess them from the start time of the next programme on the same channel. For the last programme of a channel, no stop time can be added.

Tv\_sort also performs some sanity checks such as making sure no two programmes on the same channel overlap.

**--output FILE** write to FILE rather than standard output

**--by-channel** sort first by channel id, then by date within each\
                 channel.

**--duplicate-error** If the input contains the same programme more than once,\
                      consider this as an error. Default is to silently\
                      ignore duplicate entries.

The time sorting is by start time, then by stop time.  Without **--by-channel**, if start times and stop times are equal then two programmes are sorted by internal channel id.  With **--by-channel**, channel id is compared first and then times.

You can think of tv\_sort as converting XMLTV data into a canonical form, useful for diffing two files.

## EXAMPLES

At a typical Unix shell or Windows command prompt:

- tv\_sort \<in.xml \>out.xml

  - tv\_sort in.xml --output out.xml

  These are different ways of saying the same thing.

## AUTHOR

Ed Avis, ed@membled.com
