hostgrep(1)

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

✨ hostgrep β€” print lines matching hostlist ✨

okay bestie, so picture this: you've got a big pile of files, and somewhere in there are lines that mention your hosts. hostgrep is the girl who finds them. she lives in the General Commands Manual section (section 1, iykyk), and honestly? she's iconic for this.


🌸 SYNOPSIS 🌸

hostgrep [OPTION]... HOSTLIST [FILE]...

πŸ’– DESCRIPTION πŸ’–

So what she does is: she searches the files for lines that match the hostlist you gave her. And if you hand her no files at all? No stress β€” she just searches the standard input instead. main character behavior fr.

Here's the tea on how she actually does it, per line:

  • For each line, the program tries to find all hostnames and hostlists. πŸ‘€
  • Hostlists get expanded into hostnames. (yes, hostlists are little baby hostname generators, we love that for them)
  • Then the set of hostnames in the line gets compared to the set of hostnames given by the HOSTLIST on the command line.
  • And by default? The line is printed if any hostname from the HOSTLIST is found in the line. just one match and she's satisfied, lowkey generous πŸ’…

✨ OPTIONS ✨

  • --all β€” print a line only if all hostnames in the given HOSTLIST are found in the line. she's picky now. she wants the whole squad. πŸ‘‘
  • --any β€” print a line if any hostname in the given HOSTLIST is found in the line. this is the default, it's giving chill girl energy πŸ¦‹
  • -h, --no-filename β€” do NOT show the filename in front of matching lines. this is the default if at most one FILE is given. honestly when there's only one file it's kinda redundant, she gets it πŸŽ€
  • -H, --with-filename β€” show the filename in front of matching lines. this is the default if two or more FILES are given. because with multiple files you NEED to know which one snitched πŸ”₯
  • -v, --invert-match β€” invert the sense of matching, so she selects the non-matching lines. plot twist! the lines that didn't match are now the ones on stage πŸ’€
  • -n, --line-number β€” show line number before match. receipts! so you can go back and find exactly where it was πŸ“
  • --restrict=REGEXP β€” restrict host matching to the part of the line that is matched as group 1 by this regexp. so she only looks in the little pocket of the line you pointed at, not the whole thing. targeted. precise. obsessed 🎯

🌈 EXAMPLES 🌈

1. search for lines in an accounting file where any of the three hosts is present (as a hostname or part of a hostlist):

hostgrep n[100-102] /var/log/slurm/accounting/2009-02-22

2. search for lines in the accounting files where all of the three hosts are present (as a hostname or part of a hostlist). do not show filenames:

hostgrep -h --all n[100-102] /var/log/slurm/accounting/*

3. search for lines on stdin where nodes in n[1-8] are mentioned in the part of the line that comes before the first colon:

hostgrep --restrict='^([^:]*):' n[1-8]

πŸ™ˆ BUGS πŸ™ˆ

The program has a rather naive notion of what constitutes hostnames and hostlist. she's trying her best okay 😭

and here's the lore drop, bestie, listen up:

  • For version 1.21 and earlier, hostnames were allowed to contain exactly upper and lower case A-Z and the digits 0-9. which meant you literally could not grep for names like "rack02-pos13". the hyphen said no entry. so unfair.
  • From version 1.22, the code dynamically adds additional characters from the hostlist provided on the command line, so that it will work to grep for hostnames containing those characters. character development, literally. she grew. she evolved. periodt. 🌱

πŸ‘‘ AUTHOR πŸ‘‘

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

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


🫢 SEE ALSO 🫢

hostlist (1)

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. go read it, it's short, you got this 🧚


and that's the whole page, bestie! this one's Version 2.2.1 of the page, and it's the hostgrep(1) manual page we've been vibing with the whole time. thanks for coming to my ted talk πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from