Need help in replacing a variable in shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in replacing a variable in shell scripting
# 1  
Old 06-20-2014
Need help in replacing a variable in shell scripting

Experts,

Can someone help me with the below?

I've a variable called NSPMHOME=some_value. I would like change the value of the variable with another variable and something followed by it.

E.g
From NSPHOME=some_value to NSPMHOME=$SOMETHING/test

$SOMETHING has value /opt/tag .

The end result should be $NSPMHOME=/opt/tag/test

Thanks in advance.
# 2  
Old 06-20-2014
Code:
NSPMHOME="some_value"
echo ${NSPMHOME}
some_value
SOMETHING="/opt/tag"
NSPMHOME="${SOMETHING}/test"
echo ${NSPMHOME}
/opt/tag/test

# 3  
Old 06-20-2014
Not sure I understand your problem. Assuming the missing M in NSPHOME is a typo:
Code:
NSPMHOME=$SOMETHING/test
echo $NSPMHOME 
/opt/tag/test

So... what's wrong?
# 4  
Old 06-20-2014
Erm, which is it that is correct?
Quote:
From NSPHOME=some_value to NSPMHOME=$SOMETHING/test
Is it NSPHOME or NSPMHOME ?
# 5  
Old 06-20-2014
Thanks blackrageous.

Is it possible to do using sed command?

---------- Post updated at 05:22 PM ---------- Previous update was at 05:21 PM ----------

oops, its a typo. It's NSPMHOME.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Unable to pass a space inside a variable shell scripting

Can anyone help me in solving this ? p=`date` e=`echo $p | awk '{print $2,$3}'` # echo $p Wed Aug 4 12:00:08 IST 2013 but when I am echoing the value of e it is giving me with one space. As shown below: # echo $e Aug 4 I need this value to be exact as found in... (6 Replies)
Discussion started by: Kits
6 Replies

2. Shell Programming and Scripting

Trouble with variable assignment and reading in shell scripting

Hi, I have an inputfile with some table names in it. For ex: t_arnge t_profl t_fac I need a script which reads the line one by one and need to assign to some dynamic variable. If to explain the above example: i need some a=table_name1 table_name1=t_arnge in first time and... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

3. Shell Programming and Scripting

Shell scripting Variable doubt

Dear Friends, If i give the command echo $- i am getting output of himBH. Can some body explain what does it means echo $- himBH Thanks in Advance Rajkumar (2 Replies)
Discussion started by: rajkumarin
2 Replies

4. Shell Programming and Scripting

Use case insensitive variable in ksh shell scripting using sed or awk

I am using a variable called $variable in a pattern search to print from a starting variable to a constant value. the variable search should be case in sensitive. i tired using Ip at the end in the below command. but in ksh it is not working. sed -n "/$variable/,/constant/p" file i also... (11 Replies)
Discussion started by: johnjs
11 Replies

5. Shell Programming and Scripting

searching multiple lines and replacing in shell scripting

Hi, I have a file with below contents, ssenthil = rw anilkg = rw I want to search for "ssenthil" and need to delete line 1 and 2 , if the third line starts with "" respectively and blank line immediately and third line starts with " anilkg = rw Please help me . Great day... (5 Replies)
Discussion started by: anil8103
5 Replies

6. Shell Programming and Scripting

how to store output into variable-in unix shell scripting

Hi, Output of "ps -o etime,time,pcpu,pmem,fname -C sbd-java" command is - Elapsed Time %cpu %MEM COMMAND 02:14:03 00:03:28 2.5 6.3 sbd-java Can anyone tell me, how to store the the value 2.5 in a variable? When I say echo $X where x is a variable then... (4 Replies)
Discussion started by: pspriyanka
4 Replies

7. Shell Programming and Scripting

(solved) Shell scripting to access SQLPLUS using variable

I have shell script which will try to login to SQL Plus and retrieve some data, based on the outcome i will proceed further Below is the content of the file pebblz02% cat test1.ksh #! /bin/ksh dummyvar=`sqlplus -S csm_admin/csm_admin@SIDNAME <<EOF echo hi; exit; EOF` Error message on... (0 Replies)
Discussion started by: kiranlalka
0 Replies

8. Shell Programming and Scripting

Assigning value of SQL output to a variable in shell scripting

I am trying to assgn the output of the select statement to a variable, like this "VARIABLE_NAME=$ db2 "select COLUMN_NAME_1 from TABLE_NAME where COLUMN_NAME_2='VALUE_TO_CHECK'"; " but the value that is getting into VARIABLE_NAME is "COLUMN_NAME_1 ----------------- VALUE 1... (3 Replies)
Discussion started by: sgmini
3 Replies

9. Shell Programming and Scripting

Global variable declaration in shell scripting

Hi all, How to print variable value which i have assigned inside for loop because that variable scope is local, but i want to use that variable outside for loop. Awaiting your great help Thanks, Susil (1 Reply)
Discussion started by: susilgandhi
1 Replies

10. Shell Programming and Scripting

replacing a number with random variable inside shell script

Hi All. I need help for the below logic. I ve a file like following input file: NopTX(5) // should be remain same as input ----Nop(@100); //1 Nop(90); //2 --Nop(80); //3 @Nop(70); //4 --@Nop(60); //5 @Nop@(@50); //6 --Nop@( 40); ... (3 Replies)
Discussion started by: user_prady
3 Replies
Login or Register to Ask a Question