sed -  /#/d:  not found

MTL999
MTL999 used Ask the Experts™
on
I'm not a unix person and I took a script that I'm trying to use in my environment but I'm sure I'm running into simple problems but you gotta understand in order to resolve the problem :-)

So here goes the question:

I'm getting the message: " ksh: /#/d:  not found "

The command is:
ORA_HOME=´sed /#/d ${ORATABDIR}|grep -i ${ORA_SID}|nawk -F ":" '{print $2}'´

1st of all:  what the heck is it trying to do ?  ${ORATABDIR} is a directory with more than 1 file.  I know that it wants part of string but from which file is it trying to get it from ?

2nd:  what the heck is it complaining about

Cheers
Bruno
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I would start with putting woutes around /#/d, and for the sake of it, even around the reference to ORA_SID.  This is not critical, but better.

ORA_HOME=´sed "/#/d" ${ORATABDIR}|grep -i "${ORA_SID}"|nawk -F ":" '{print $2}'´


More critical is that the
 ´   characters
do not mean much, they should be quotes like:
'
or in the present case probably like this:
`
which makes sure that the entire 'string' gets executed.

if ORATABDIR is a directory then this is not going to work.  'sed' expects a file (unless there is a special version of 'sed' around).  You might need to add '/*'  to check all the files;


What does it complain about?:
When you write something like this:
VAR=value command

The the context in which command is run is modified: the environment variable 'VAR' will have 'value' as its content.

The complaint is related to what I wrote above: ´ does not have any signification: it does not start a string, neither does it start a string that should be executed like `does .  So basically  
ORA_HOME=´sed
corresponds to an assignment
and
/#/d
is expected to be a command to execute.   So 'ksh' complains that it can not find '/#/d' as a command (an executeable file in the PATH having '/#/d' as its name).



What is it trying to do?
- Apparently it removes comment lines from a file;
- finds the line containing $ORA_SID
- returns the string following between the first (and second) ':'
Gerwin Jansen, EE MVETopic Advisor
Most Valuable Expert 2016

Commented:
Hi, the script is trying to set ORA_HOME based on contents of ${ORATABDIR} and ${ORA_SID}

We could debug easier if you show the contents of the 2 variables:

echo ${ORATABDIR}
echo ${ORA_SID}
Gerwin Jansen, EE MVETopic Advisor
Most Valuable Expert 2016

Commented:
And the contents of the file ${ORATABDIR} as well, leave out any specific details.

cat ${ORATABDIR}

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial