Need help in Case Command

Hi All

I am trying to replace some character using Sed , but i also need to use case commands

like this :
x=`who am i`
opt=`echo ${x} | cut -f1 -d' '`
case $opt in
unix) 'UNX'

My script asks the user to enter the source server and it gets the results

it has to reaplace the above string with the new server name

example :

filename xx.txt
df -k <UNIX> to df -k <UNX>

Thanks

I hope this will work. Please reply whether it has worked or not

x=`who am i`
opt=`echo ${x} | tr -s " " | cut -d " " -f1`
case $opt in
unix) sed 's/unix/UNX/g'

See the in the tr -s command, with in the quotes I have included 4 spaces.. It might not be clearly visible for you once my reply is submitted

Thanks for the reply

I have question in this

I am Prompting the User for the Source instance name :

echo " Please enter the Source databse :"
read p1

The shell runs from the target and the unix id can be easily determined by the above shell , but my concern is how case can identify these conditions

Please let me know , if this confusing

I could not understand what u r saying and what is the final output u desire?

Will you please illustrate more with an example?

Just to be clear ,

I need to replace a string in a file

i am asking the user to enter the Source Server

and since the script is run from the target , i can get the UNIX id

how will i replace some characters based on "CASE" condition

example:

UNX has to be replaced bye UNIX

lets Assume my source server is unix1 and my target is unix2

its static , that if unix1 is the server then the string will be x1 and unix2 is the server x2 is constant

so source is unix1 (which will be given by the user )

logged in unix2 , so x1 has to be replaced by x2

Please note i have so many instances like that , so CASE should be the better option

Please help me on this ??

see if your instances are like unix1, unix2 etc.. See you are changing last character by keeping the rest of the server instane name same. I want to know whether all the instance name you are having will having some common characters among them. If so, how many?

This is for my knowledge - how will you find the Server instance, I meant, what is the command?