1834226 Members
2363 Online
110066 Solutions
New Discussion

command help

 
SOLVED
Go to solution
Joyce Suganthy
Advisor

command help

Hi All,

I need some help.
If I have a cluster with three servers, hostname abc1,abc2,abc3.

I need to write a script to compare files in all three servers, where i am gonna use the remsh command.
Say for example if the $var = abc1, then look for the abc2 and abc3 and do the remsh. How do i cut only the characters in the hostname like abc1, i only wanna pick up the 'abc' and then continue the process from there, so i need not hardcode the hostname, as I have many clusters in hand.

Thanks

Regards
3 REPLIES 3
Mark Grant
Honored Contributor
Solution

Re: command help

This works for me

characters=`expr $hostname : "\([^0-9]*\)"`
Never preceed any demonstration with anything more predictive than "watch this"
Leif Halvarsson_2
Honored Contributor

Re: command help

Hi,
Another solution:
a=$(echo abc1 |tr -d [:digit:])
echo $a
Steven Sim Kok Leong
Honored Contributor

Re: command help

Hi,

Here's another way:

echo $var | sed 's/[0-9]//g'

Hope this helps. Regards.

Steven Sim Kok Leong