Resolving the UNIX path variable


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Resolving the UNIX path variable
# 1  
Old 07-30-2019
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 ;

Code:
app_dir=/project/emp
abc_dir=${app_dir}/abc/app

abc_common=${abc_dir}/common
abc_common_base=${abc_common}/base
abc_common_metadata=${abc_common}/metadata
abc_ddmsupply_dir=${abc_dir}/ddm_supply
abc_xyz_dir=${abc_ddmsupply_dir}/xyz
hdfs_abc_app_dir=/emp/abc
hdfs_abc_supply_app_dir=${hdfs_abc_app_dir}/ddm_supply

#Application Specifics 

#xyz 
abc_xyz_dir=${abc_ddmsupply_dir}/xyz
hdfs_abc_xyz_app_dir=${hdfs_abc_supply_app_dir}/xyz
abc_xyz_temp_dir=${abc_xyz_dir}/temp
abc_xyz_shell_dir=${abc_xyz_dir}/shell
abc_xyz_shell_dly_dir=${abc_xyz_shell_dir}/daily
abc_xyz_prp_dir=${abc_xyz_dir}/properties
abc_xyz_control_dir=${abc_xyz_dir}/control
abc_xyz_error_dir=${abc_xyz_dir}/errors
abc_xyz_fw_dir=${abc_xyz_dir}/fileWatcher
abc_xyz_logs_dir=${abc_xyz_dir}/logs
abc_xyz_notif_dir=${abc_xyz_dir}/notifications
abc_xyz_job_dir=${abc_xyz_dir}/code
abc_xyz_job_dly_dir=${abc_xyz_job_dir}/daily
abc_xyz_job_dly_cont_dir=${abc_xyz_job_dly_dir}/controls/
abc_xyz_job_ldid_dly_dir=${abc_xyz_job_dly_cont_dir}/load_id 
abc_xyz_base_dir=${abc_xyz_dir}/base

Please let me know an easy way of expanding all the variables into unix path

thanks
Arun
# 2  
Old 07-30-2019
start with:
Code:
. master_config.sh

PATH="$PATH:$(set | awk -F= 'NR==FNR {vars[$1]=$2; next} vars[$1] && ! ovars[$2]++ {printf $2 ":"}' master_config.sh -)"

# 3  
Old 07-30-2019
thank you !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

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. db $ grep -v "^#" TD_FWK_NUCLEUS.dbc | grep -v "^$" | xargs -i echo {} wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG} I... (3 Replies)
Discussion started by: Mohammed Rafi
3 Replies

4. UNIX for Advanced & Expert Users

Difference between Unix and Linux for resolving symbols

I came across a difference between Unix and Linux, when it comes to resolving the symbols from the libs. consider the following code segments... $ cat call1.c #include <stdio.h> int a1; extern int a3; void prnt_a3() { printf("\n%d\n",a3); } $ cat test.c #include <stdio.h>... (12 Replies)
Discussion started by: snowline84
12 Replies

5. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

6. Shell Programming and Scripting

Appending a path in user's PATH variable

Hello Folks, I want to append a path in user's PATH variable which should be available in current session. Background Numerous persons will run a utility. Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

7. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

8. Shell Programming and Scripting

remove a path from PATH environment variable

Hi I need a script which will remove a path from PATH environment variable. For example $echo PATH /usr/local/bin:/usr/bin:test/rmve:/usr/games $echo rmv test/rmve Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
Discussion started by: madhu84
9 Replies

9. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

10. Shell Programming and Scripting

Getting the path from a variable

Hi, I am having a variable Like line="/dir1/dir2/gr3/file.ksh" I need to get the /dir1/dir2/gr3 alone. the no of directories may differ at each time. Please advice. thanks in advance. (3 Replies)
Discussion started by: vanathi
3 Replies
Login or Register to Ask a Question