pyUTok - Unique TOKens in python

Inspired by a tool I can not find anymore on the internet: utok 1.5. I use it to clean up path settings in large shell script configuration setups.

utok has the following options:

usage: utok [-h] [--delimiter DELIMITER] [--delete-list DELETE_LIST] [--version] tokens [tokens ...]

Positional Arguments


Named Arguments

--delimiter, -s

Allows one to change the delimiter. If you use csh you might want to set your path with something like: set path = (utok -s /usr/local/bin $path)

Default: “:”

--delete-list, -d

Allows one to remove tokens from a list, to remove /usr/sbin and . from a path in Bourne Shell one might use: PATH=`utok $PATH -d .:/usr/sbin`

--version, -V

show program’s version number and exit


The latest version should be available at my GitLab repository, the package is avaliable at pypi via pip install pyutok.


utok, Unique TOKens, takes a list of arguments with delimiters and reject all duplicate entries. Here is a example using MANPATH:

$ echo $MANPATH
$ MANPATH=`utok /home/local/man /usr/local/man $MANPATH /usr/openwin/man`
$ export MANPATH
$ echo $MANPATH

Even though /usr/local/man was included a second time it is only in the MANPATH once, though it is now before the /usr/man entry instead of after it.

This version adds the -d option to remove tokens. To remove . from the PATH one would do the following:

$ echo $PATH
$ PATH=`utok -d .: $PATH`
$ echo PATH
$ export PATH

Requested Features

  • Have a way to to push an element further back in the path. A work around of this would be be something like:

    utok `utok a:b:c:d -d b` b

    which returns: a:c:d:b

  • Have a way to include multiple -s options.


Comments or bug reports/fixes go to Berthold Höllmann <>.

Copyright © 2020 Berthold Höllmann <>

Original C version: Copyright © 1998 Sven Heinicke <>


Process token.


Indices and tables