bibi92
asked on
question about awk
Hello,
I have a file in variable $Dbprp which content :
hostname1_1511_db1.world
hostname2_1512_db2.world
hostname3_1513_db3.world
hostname4_1514_db4.world
hostname5_1515_db5.world
For each line, I search to get three following variables
host = hostname1
port = 1511
base = db1
I try this, but the result for base is hostname1_1511_db1.world. How can I resolve?
for db in `cat $Dbprp`
do
[ ! $db ] && db="error listener.ora" # pb get db on listener.ora files
echo $db
host=`echo $db | awk -F'_' '{ print $1 }'`
port=`echo $db | awk -F'_' '{ print $2 }'`
base=`echo $db | awk -F'_' '{ print $3 }'| sed 's/.world//g'`
done
Thanks
Regards
I have a file in variable $Dbprp which content :
hostname1_1511_db1.world
hostname2_1512_db2.world
hostname3_1513_db3.world
hostname4_1514_db4.world
hostname5_1515_db5.world
For each line, I search to get three following variables
host = hostname1
port = 1511
base = db1
I try this, but the result for base is hostname1_1511_db1.world. How can I resolve?
for db in `cat $Dbprp`
do
[ ! $db ] && db="error listener.ora" # pb get db on listener.ora files
echo $db
host=`echo $db | awk -F'_' '{ print $1 }'`
port=`echo $db | awk -F'_' '{ print $2 }'`
base=`echo $db | awk -F'_' '{ print $3 }'| sed 's/.world//g'`
done
Thanks
Regards
ASKER
Hello,
With this command :
echo "insert into test values (''' || $host || '''' || ',' || '''' || $port || '''' || ',' || '''' || $base|| '''' ||',null,trunc(sysdate));" >> $WorkFile
Thanks
With this command :
echo "insert into test values (''' || $host || '''' || ',' || '''' || $port || '''' || ',' || '''' || $base|| '''' ||',null,trunc(sysdate));"
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry but we haven't the same result and for the simple loop :
IFS+=_.: not found
Thanks
IFS+=_.: not found
Thanks
What do you get in $WorkFile?
Which shell are you using?
Which shell are you using?
ASKER
I've requested that this question be deleted for the following reason:
I have found a solution with delete || in insert statement thanks regards
I have found a solution with delete || in insert statement thanks regards
What is the solution with delete || in insert statement?
What do you get in $WorkFile?
Which shell are you using?
What do you get in $WorkFile?
Which shell are you using?
ASKER
You are right. I have forgotten I changed the output for insert in Oracle db. Thanks regards
How did you determine that the result for base is hostname1_1511_db1.world?