Reading a path (including ref to shell variable) from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a path (including ref to shell variable) from file
# 1  
Old 09-10-2006
Reading a path (including ref to shell variable) from file

Hi!

1. I have a parameter file containing path to log files. For this example both paths are the same, one is stated directly and the second using env variables.

/oracle/admin/orcl/bdump/:atlas:trc:N
${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/:${ORACLE_SID}:trc:N

2. I try to parse the path names from ini file

#!/bin/bash
LOG_TARGETS="./log_targets.ini"
cat $LOG_TARGETS | while read LINE
do
case $LINE in
\#*) ;; #comment-line
*)
DIR=`echo $LINE | awk -F: '{print $1}' -`
echo $DIR
if [ ! -d $DIR ] ; then
echo "Warning: directory $DIR is not valid"
fi
esac
done

output ...

/oracle/admin/orcl/bdump/
${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/
Warning: directory ${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/ is not valid

I am not able to get the pathname for the second entry!
Lets check the env settings

$ echo $ORACLE_BASE
/oracle
$ echo $ORACLE_SID
atlas
$ echo ${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/
/oracle/admin/orcl/bdump/

3. If I try it directly from bash

$ LINE="$ORACLE_BASE/admin/$ORACLE_SID/bdump/:${ORACLE_SID}:trc:N"
$ echo $LINE | awk -F: '{print $1}' -
/oracle/admin/orcl/bdump/

then the result is ok. (but not in the mentioned script above)

Any suggestions?
# 2  
Old 09-11-2006
Found it!

DIR=`echo $LINE | awk -F: '{print $1}' -`
eval DIR=$DIR
echo $DIR
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use printf to output a shell variable path?

So I created two shell variables: COLUMN1_HEADING, COLUMN2_HEADING. They have values: COLUMN1_HEADING="John" COLUMN2_HEADING="123456789" How would I use printf to get it to print an output like this: $COLUMN1_HEADING\t$COLUMN2_HEADING\nJohn\t123456789\n Thanks! (3 Replies)
Discussion started by: steezuschrist96
3 Replies

2. Shell Programming and Scripting

How to use ls with pattern and including path?

Hello to all, Maybe someone could help me, my question is: How can a filter the print of command ls for the files with names of the form "abc*.txt" including the path? I've done this: If I move with command cd to /My/Path/Is/This/ and send this command: ls -lst abc*.txt -i... (37 Replies)
Discussion started by: Ophiuchus
37 Replies

3. Shell Programming and Scripting

Find file and zip without including directory path

Does anyone know of a way to zip the resulting file from a find command? My approach below finds the file and zips the entire directory path, which is not what I need. After scanning the web, it seems to be much easier to perform gzip, but unfortunately the approach must use zip. find `$DIR`... (5 Replies)
Discussion started by: koeji
5 Replies

4. Shell Programming and Scripting

C Shell path variable causing very slow shell!?HELP

I am using C Shell MKS Toolkit and I ran into a huge problem when setting up some environment variables.:confused: The csh script that I have as my login script runs fine but very very slow. When I add a directory to my PATH it seems to slow down shell startup and even slow down the commands. ... (0 Replies)
Discussion started by: vas28r13
0 Replies

5. Shell Programming and Scripting

How to filter only comments while reading a file including line break characters.

How do I filter only comments and still keep Line breaks at the end of the line!? This is one of the common tasks we all do,, How can we do this in a right way..!? I try to ignore empty lines and commented lines using following approach. test.sh # \040 --> SPACE character octal... (17 Replies)
Discussion started by: kchinnam
17 Replies

6. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

7. UNIX for Dummies Questions & Answers

Reading a line including spaces

Hi All, I have a script that reads a file and echo it back to std out. Test.txt 1aaaaaaaaaaa . The script is ReadLine.sh #!/bin/ksh cat $1 | while read file do echo $file done I invoke the script as ReadLine.sh Test.txt The output that I get is (1 Reply)
Discussion started by: aksarben
1 Replies

8. Shell Programming and Scripting

Set Path variable in c shell

I set my path environment variable in c shell, using the syntax below setenv PATH "${PATH}:/usr/local:/usr/local/bin" and placed this in $HOME/.login $HOME/.cshrc and /etc/.login /etc/.cshrc but when I issued echo $PATH or set command the output does not reflect changes made to... (5 Replies)
Discussion started by: hassan2
5 Replies
Login or Register to Ask a Question