Ask Your Question

Get last character of hostname

asked 2014-08-29 01:11:59 -0600

adrianwxn gravatar image


I have a cluster composed of the following nodes linux01a linux02b I need to get the last letter of the node for some customization.


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-08-29 14:00:07 -0600

jzimmerman gravatar image

The template method is good if you need to grab the last character. If you just want to match on it you can do something like...

case $::hostname {

  /(b$)/:  { stuff for b here }

  /(a$)/:  {stuff for a here }

  default: { default stuff here }

edit flag offensive delete link more

answered 2014-08-29 10:40:05 -0600

ramindk gravatar image

I usually use inline_templates.

 $my_cluster = inline_template('<%= @hostname[-1,1] %>')
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-08-29 01:11:59 -0600

Seen: 679 times

Last updated: Aug 29 '14