Hello all,
I am new to bash. I am trying to get a sub string of a variable in a shell script. While trying to do that I get the following error:
------------------------------------------------------------------------
OHOME: /aaa/bbb/product/eee
./t.sh: line 6: /aaa/bbb/product/eee: No such file or directory
Oracle Base:
------------------------------------------------------------------------
Here is the code:
------------------------------------------------------------------------
#!/bin/sh
OHOME=/aaa/bbb/product/eee
echo " OHOME: "$OHOME
O_BASE=echo $OHOME | awk -F"/" '{for(i=2;i<=NF;i++) {if($i=="product"){exit;} a=a"/"$i; }} '
echo " Oracle Base: "$O_BASE
------------------------------------------------------------------------
I am very surprised. Since it does not seem to like "echo $OHOME" I tried several things like enclosing in brackets, single/double quotes, etc. I still get this error. I cannot seem to find the syntax from the book or google
Looks very simple, but I am stuck on this for hours. Maybe experts here can guide me.
Here is our Linux version:
Linux <name> 2.6.9-67.0.20.ELsmp #1 SMP Wed Jun 18 12:40:47 EDT 2008 i686 i686 i386
GNU/Linux
Rocky.