hostlist - handle hostlist expressions
hostlist [OPTION]... [HOSTLIST]...
Perform a set operation (union, intersection, difference or
symmetric difference) on the given hostlists. Output the result as a
hostlist, a count of hostnames or an expanded list of hostnames.
If "-" is used instead of a hostlist argument, an
arbitrary number of hostlists are read from stdin. The union of them is used
as if it had been present on the command line as a single hostlist
argument.
- -u, --union
- Compute the union of the hostlists. A hostname is present in the output if
it is included in at least one of the hostlists. This is the default
operation.
- -i, --intersection
- Compute the intersection of the hostlists. A hostname is present in the
output if it is included in all the hostlists.
- -d, --difference
- Compute the difference of the hostlists. A hostname is present in the
output if it is included in the first hostlist but not any of the
following.
- -x,
--symmetric-difference
- Compute the symmetric difference of the hostlists. A hostname is present
in the output if it is included in an odd number of the hostlists.
- -o OFFSET,
--offset=OFFSET
- Filter the result to skip OFFSET hosts from the beginning. If
OFFSET is not less than the number of hosts in the result, the
result will become empty. If OFFSET is negative, keep
-OFFSET hosts from the end of the result. The default is to skip
nothing.
- -l LIMIT,
--limit=LIMIT
- Filter the result to limit it to the first LIMIT hosts. If
LIMIT is not less than the number of hosts in the result, this
option does nothing. This filter is applied after the --offset
filter (see above). The default is to have no limit.
- -c, --collapse
- Output the result as a hostlist expression. This is the default. See the
--chop option for splitting into multiple hostlists of a certain
size.
- -n, --count
- Output the number of hostnames in the result.
- -e, --expand
- Output the result as an expanded list of hostnames.
- -w
- Output the result as an expanded list of hostnames. This option is
deprecated. Use -e or --expand instead.
- -q, --quiet
- Output nothing. This option is useful together with
--non-empty.
- -0, --non-empty
- Return success if the resulting hostlist is non-empty and failure if it is
empty.
- -s SEPARATOR,
--separator=SEPARATOR
- Use SEPARATOR as the separator between the hostnames in the
expanded list (and between (chopped) hostlists in collapsed mode). The
default is a newline.
- -p PREPEND,
--prepend=PREPEND
- Output PREPEND before each hostname in the expanded list (and
before each hostlist in collapsed mode). The default is to prepend
nothing.
- -a APPEND,
--append=APPEND
- Output APPEND after each hostname in the expanded list (and after
each hostlist in collapsed mode). The default is to append nothing.
- -S FROM,TO,
--substitute=FROM,TO
- Apply a regular expression substitution to each hostname, replacing all
FROM with TO. The default is to do no substitution.
- --append-slurm-tasks=SLURM_TASKS_PER_NODE
- Append the number of tasks parsed from the SLURM_TASKS_PER_NODE
string. You need to use -e/--expand and you probably need to
specify -a/--append and -s/--separator too. NOTE: The
hostlist is always sorted internally by this program. The task counts from
SLURM_TASKS_PER_NODE is then applied to each hostname in the sorted
list.
- --repeat-slurm-tasks=SLURM_TASKS_PER_NODE
- Repeat each hostname so it is listed multiple times as specified by the
SLURM_TASKS_PER_NODE string. You need to use -e/--expand.
NOTE: The hostlist is always sorted internally by this program. The task
counts from SLURM_TASKS_PER_NODE is then applied to each hostname
in the sorted list.
- --chop=CHUNKSIZE
- When outputting as collapsed hostlist (the default mode --collapse)
split into hostlists of size CHUNKSIZE and output each hostlist
separately. The last hostlist may be smaller than the rest.
- --version
- Show the version of the utility and the underlying Python library.
Written by Kent Engström <kent@nsc.liu.se>.
The program is published at
http://www.nsc.liu.se/~kent/python-hostlist/
The square brackets used in the hostlist expression syntax are
also used in shell glob patterns. This may cause unwanted surprises if you
have files in your current directory named after hosts present in the
hostlist. Always quote the hostlist expression to avoid this problem:
% hostlist n[1-10]
n[1-10]
% touch n1
% hostlist n[1-10]
n1
% echo n[1-10]
n1
% hostlist "n[1-10]"
n[1-10]
The hostlist expression syntax is used by several programs
developed at LLNL (https://computing.llnl.gov/linux/), for example
SLURM (https://computing.llnl.gov/linux/slurm/) and Pdsh
(https://computing.llnl.gov/linux/pdsh.html).
See the HOSTLIST EXPRESSIONS section of the pdsh(1)
manual page for a short introduction to the hostlist syntax.