clustershell icon indicating copy to clipboard operation
clustershell copied to clipboard

RFE: `nodegrep`, a wrapper or tool to make `grep node-[1,4,7-8],@ngrp /var/log/messages` do the right thing.

Open griznog opened this issue 5 years ago • 3 comments

I find myself grepping for node names often and building "(node1|node2|thisnode|thatnode)" style expressions often, just occurred to me today that many times these will collapse into a noderange or in some cases I what I really want to do isnodegrep sp@batch ... for some predefined group in my clustershell config. Haven't moved the thought process far enough along to decide how hard this would be to do or how to do it yet, just throwing it out as an idea.

Or if there is already a way to do this, appreciate a pointer to how.

griznog avatar Sep 16 '20 13:09 griznog

You can make a small script or even a shell function that does that for you:

nodegrep() {
  local SET="$1"
  shift
  grep -F "$(nodeset -S'\n' -e "$SET")" "$@"
}

martinetd avatar Sep 16 '20 14:09 martinetd

Brilliant, thank you @martinetd !

griznog avatar Sep 16 '20 16:09 griznog

(might want to add -w to the grep, in case you don't pad node numbers, to avoid e.g. example1 from matching example102 or whatever)

martinetd avatar Sep 16 '20 18:09 martinetd