I copied my .csshrc to a new machine, and needed to add a domain suffix to the hostnames of 20+ VMs in my cluster config. All of my hostnames end in at least 2 digits (foo-bar-baz-01), so I:
- Search for instances of 2 digits followed by whitespace.
- Preserve the digits in a capture group.
- Append the suffix to the capture group (\1)
Append domain suffix where none exists:
Search: ([0-9]{2})\s
Replace: \1.my.domain.suffix