hostlist(1)
π 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 skipOFFSEThosts from the beginning. IfOFFSETis not less than the number of hosts in the result, the result will become empty π. IfOFFSETis negative, keep-OFFSEThosts from the end of the result. The default is to skip nothing.-l LIMIT,--limit=LIMITβ Filter the result to limit it to the firstLIMIThosts. IfLIMITis not less than the number of hosts in the result, this option does nothing. This filter is applied after the--offsetfilter (see above). The default is to have no limit.-c,--collapseβ Output the result as a hostlist expression. This is the default. See the--chopoption 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-eor--expandinstead, 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β UseSEPARATORas 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β OutputPREPENDbefore each hostname in the expanded list (and before each hostlist in collapsed mode). The default is to prepend nothing.-a APPEND,--append=APPENDβ OutputAPPENDafter 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 allFROMwithTO. 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 theSLURM_TASKS_PER_NODEstring. You need to use-e/--expandand you probably need to specify-a/--appendand-s/--separatortoo. NOTE: The hostlist is always sorted internally by this program. The task counts fromSLURM_TASKS_PER_NODEis 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 theSLURM_TASKS_PER_NODEstring. You need to use-e/--expand. NOTE: The hostlist is always sorted internally by this program. The task counts fromSLURM_TASKS_PER_NODEis then applied to each hostname in the sorted list.--chop=CHUNKSIZEβ When outputting as collapsed hostlist (the default mode--collapse) split into hostlists of sizeCHUNKSIZEand 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
- debian trixie: python3-hostlist 2.2.1-2 Β· GPL-2.0-or-later
- ubuntu resolute: python3-hostlist 2.2.1-2 Β· GPL-2.0-or-later
- ubuntu stonking: python3-hostlist 2.2.1-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms