hostlist(1)

πŸ“¦
version 2.2.1 Β· 2 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– hostlist β€” handle hostlist expressions πŸ’–

okay bestie, welcome to the hostlist(1) page, straight outta the General Commands Manual ✨ this lil cutie handles hostlist expressions and honestly? it's giving main character energy πŸ‘‘


🌸 SYNOPSIS 🌸

hostlist [OPTION]... [HOSTLIST]...

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does this do? It performs a set operation (union, intersection, difference or symmetric difference) on the hostlists you hand it πŸ’…. Then it outputs the result as a hostlist, a count of hostnames, or an expanded list of hostnames. Pick your vibe.

And here's a lil secret trick 🫢 β€” if you drop a - instead of a hostlist argument, an arbitrary number of hostlists get read from stdin. Their union is used as if it had been sitting right there on the command line as a single hostlist argument. iconic.


✨ OPTIONS ✨

  • -u, --union β€” Compute the union of the hostlists. A hostname shows up in the output if it's included in at least one of the hostlists. This is the default operation, so it's the no-thoughts-just-vibes choice πŸ’–
  • -i, --intersection β€” Compute the intersection of the hostlists. A hostname shows up in the output if it's included in all the hostlists. everyone has to agree or it's not invited βœ‹
  • -d, --difference β€” Compute the difference of the hostlists. A hostname shows up in the output if it's included in the first hostlist but not any of the following. first one ate and the rest didn't, periodt.
  • -x, --symmetric-difference β€” Compute the symmetric difference of the hostlists. A hostname shows up in the output if it's included in an odd number of the hostlists. yes the math is mathing πŸ”₯
  • -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. just the number, bestie πŸ”’
  • -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, fr fr.
  • -q, --quiet β€” Output nothing. This option is useful together with --non-empty. silence but make it purposeful 🀫
  • -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. glow-up for your hostnames πŸ’…
  • --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. 🐍

πŸŽ€ EXAMPLES πŸŽ€

Output the union of n[10-19] and n[15-24] (which is n[10-24]):

hostlist n[10-19] n[15-24]

Output the result of removing n15 and n[17-18] from n[1-20] (which is n[1-14,16,19-20]):

hostlist -d n[1-20] n15 n[17-18]

Output the result as an expanded list of hostnames (one hostname per line):

hostlist -d -e n[1-20] n15 n[17-18]

Output the result as an expanded list of hostnames separated by commas:

hostlist -d -e -s, n[1-20] n15 n[17-18]

Output the result as an expanded list of hostnames (followed by space and the digit "8") separated by spaces:

hostlist -d -e -s " " -a " 8" n[1-20] n15 n[17-18]

Expand a hostlist, replacing "n" with "ni":

hostlist -e -S n,ni n[1-20]

Print INCLUDED as n11 is in n[10-20]:

if hostlist -q0 -i n11 n[10-20]; then echo INCLUDED; else echo
NOT INCLUDED; fi

πŸ‘‘ AUTHOR πŸ‘‘

Written by Kent EngstrΓΆm <kent@nsc.liu.se>.

The program is published at http://www.nsc.liu.se/~kent/python-hostlist/ 🫢


⚠️ NOTES ⚠️

okay this part is important so listen up bestie 😭 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]
no cap, quote your hostlists. the shell will betray you otherwise πŸ’€

🌈 SEE ALSO 🌈

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. iykyk πŸ¦‹


and that's the whole page, bestie ✨ this was Version 2.2.1 of hostlist(1), so go forth and handle those hostlist expressions like the icon you are πŸ’–πŸŒΈπŸŽ€

πŸ“¦ where this page comes from