Need help in Case Command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in Case Command
# 1  
Old 12-07-2007
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
# 2  
Old 12-07-2007
Question

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
# 3  
Old 12-07-2007
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
# 4  
Old 12-07-2007
I could not understand what u r saying and what is the final output u desire?

Will you please illustrate more with an example?
# 5  
Old 12-07-2007
Bug

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 ??
# 6  
Old 12-07-2007
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to ignore Case with in COMM command?

Hi, How can i ignore case between 2 files in unix using COMM command. 2 input files are: -bash-4.1$ more x2.txt HELLO hi HI raj -bash-4.1$ more x3.txt hello hi raj COMM command: -bash-4.1$ comm x2.txt x3.txt hello HELLO hi (3 Replies)
Discussion started by: raju2016
3 Replies

2. Shell Programming and Scripting

Please help me in using case sensitive command

Hello All, Please help me with this I need to create a cronjob that should delete all files which are older than 30days with '*.txt' and should not delete files with '*TEST*.txt' either file name TEST is upper or test lower case sensitive here's the script /DIR -type f -name '*.txt'... (7 Replies)
Discussion started by: krish_007
7 Replies

3. Shell Programming and Scripting

Clarification on Case command

Hi, I'm a newbie to shell programming and have just written a small program to transfer files. # job variables RunMode=$1 export DATETIME=`date +%Y%m%d%H%M%S` export STARTTIME=`date +%Y%m%d%H%M` export ShellDir=/rosetlt/scripts/ksh export LogDir=/rosetlt/scripts/log export... (2 Replies)
Discussion started by: narayanv
2 Replies

4. Shell Programming and Scripting

Case conversion within a command

Hi All, I need the variable to be set in both uppercase and lowercase in a single command DATABASE=ORCL something like the below which is absolutly wrong find /ora/admin/11.1.0/diag/rdbms/{print tolower($0)}${DATABASE}/{print toupper($0)}${DATABASE} The o/p should be as below:... (4 Replies)
Discussion started by: jjoy
4 Replies

5. UNIX for Dummies Questions & Answers

Command for a case insensitive search

Hi All, What is the command to search a file for a case-insensitive match 1.grep -nc text filename 2.grep -i text filename 3.grep -i filename text 4.grep -nc filename text 5.grep -c text filename Thanks for your help (1 Reply)
Discussion started by: bobby1015
1 Replies

6. Shell Programming and Scripting

making sed command case insensitive

i have something like this in a file cat onlytables.sql create table NextID ( id int auto_increment, zoneID int, entityName varchar(64), nextID int, lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, primary... (6 Replies)
Discussion started by: vivek d r
6 Replies

7. UNIX for Dummies Questions & Answers

more command case insensitive search ?

Hello, How do I set case insensitive search mode while the file is open with more command ? (I know -i option which could be used before opening) thanks Vilius (2 Replies)
Discussion started by: vilius
2 Replies

8. UNIX for Dummies Questions & Answers

Including case insensitivity into loop command

I have the following piece of code: for file in *csv; do cat $file >> $newfile; done for file in *CSV; do cat $file >> $newfile; done and would like to know how to combine these two rules into one? The combined rule would then include the case insensitivity that I am looking for. (4 Replies)
Discussion started by: figaro
4 Replies

9. Shell Programming and Scripting

case command inside awk/nawk

well I found lot of topics about awk..about if command in awk.. but I had to implement this: nawk -F"|" ' $47 ~ /0R0011/ { print > ("/home/user/M/MC.tmp" )} $47 ~ /0R0012/ { print > ("/home/user/M/DuSI.tmp" )} $47 ~ /0R0014/ { print > ("/home/user/M/FF.tmp" )} $47 ~ /0R0018/ { print >... (9 Replies)
Discussion started by: abdulaziz
9 Replies

10. UNIX for Dummies Questions & Answers

Case statement/sed command

The file dbnames.txt has 5 columns, what i'm trying to do is that when the fifth column equals A, store in the variable "access" the word, "admin access". If it equals B, then "business access" etc. I think their is a problem with my sed command, because it is not substibstituting the words... (1 Reply)
Discussion started by: ross_one
1 Replies
Login or Register to Ask a Question