Resolving the environment variable from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Resolving the environment variable from a file
# 1  
Old 02-01-2013
Resolving the environment variable from a file

Hi,

I an having some environment variables exported and the variable name is present in the file. But its not resolving with following commands. Can someone throw some light.
Code:
db $ grep -v "^#" TD_FWK_NUCLEUS.dbc | grep -v "^$" | xargs -i echo {}
wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG}

I wanted the value instead of the variable name.

Expected output :
Code:
db $ echo "wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG}"
wb_bin: /opt/teradata/client/13.0/tbuild/bin


Last edited by Franklin52; 02-01-2013 at 07:03 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 02-01-2013
The way you asked the question is quite confusing.
Could you please clarify ?

What is the name of your script ?
what is the content of your script ?

Maybe you can give a try to this :
Code:
egrep -ve "^#|^$" TD_FWK_NUCLEUS.dbc | while read line;do eval echo "$line";done

I don't know exactly what you are trying to achieve, but I suspect your approach could be enhanced a lot.

Last edited by ctsgnb; 02-01-2013 at 07:07 AM..
# 3  
Old 02-01-2013
Many thanks, Its working with while.

Its not a script. It was a txt file in which the variable names are there which is environment variables. Tried to get the values; but could not with echo. while is working fine,.
# 4  
Old 02-01-2013
To load a file that contains environnement variable settings use the <dot><space><filename> notation.

Code:
. /home/your_env_file

Or if you are in c-shell (which should be avoid if possible)

Code:
source /home/your_env_file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Resolving the UNIX path variable

Friends, I trying to get the unix path fro a config file. There are 100 + path variables defined in the master_config.sh. Like this ; app_dir=/project/emp abc_dir=${app_dir}/abc/app abc_common=${abc_dir}/common abc_common_base=${abc_common}/base... (2 Replies)
Discussion started by: arunv123
2 Replies

2. UNIX for Beginners Questions & Answers

Help for resolving Unexpected EOF while assigning value to variable

#!/bin/sh . /opt/ora/oracle/db/tech_st/11.2.3/PROD_proddb.env sqlplus -s "username/password" << EOF no='sqlplus -s username/password<<EOF set heading off set feedback off Select pt.user_concurrent_program_name report_name , OUTFILE_NAME report_path FROm apps.fnd_concurrent_programs_tl... (12 Replies)
Discussion started by: usman_oracle
12 Replies

3. Shell Programming and Scripting

Variable in not resolving in sed

I'm trying to search the 2 pattern in consecutive lines and print them but my variables are not resolving in sed (using bash shell) - # cat testfile2.txt Fixing Storage Locations to remove extra slash; Fixing Storage Locations to remove extra slash; Fixing Storage Locations to remove extra... (2 Replies)
Discussion started by: Mannu2525
2 Replies

4. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

5. Shell Programming and Scripting

Set Environment variable from another file

Hi, i have the following env variable. currently i am exporting variable in the same script file. but i need this is in a text file and the scripts need to export this variable from the text file. can you please suggest me. is it possible. export... (6 Replies)
Discussion started by: rsivasan
6 Replies

6. Shell Programming and Scripting

Setting Environment variable from value in file

I've searched Google and now this forum. Best guess is my search fu is not good (and it probably isn't). The Google search did bring me here. Background I have a number of Korn Shell scripts who all use one of 3 values for an environment variable used in the backup system. On occasion one or... (8 Replies)
Discussion started by: WolfBrother
8 Replies

7. Linux

How to create file on Linux using environment variable in the dirpath

Hi all, I am running a Java program on a Linux server in which I read in a base directory path from the *.properties file. During processing, I build a unique file name and create a file to save data, concatenating the directory path and the file name. Works fine, except that I now need to... (2 Replies)
Discussion started by: patricia1of5
2 Replies

8. Shell Programming and Scripting

environment variable

Hi, I have to set bunch of variables and all other programs like make, perl will use them .. Here are my constraints and requirements ... The variables have to be set by executing a script that runs in c shell. I cannot source the script since people who use this script might be on... (8 Replies)
Discussion started by: sharanbr
8 Replies

9. Shell Programming and Scripting

Environment Variable

First of all I am using C shell. I have a variable destDirectory that holds a path. the path includes an environment variable($user) when I try to execute a command within the script, the $destDirectory gets replaced with the path, but the environment variable is not replaced. I end up... (2 Replies)
Discussion started by: karyn1617
2 Replies
Login or Register to Ask a Question