I need to extract variables in first column ('203969','203970','203971'...) and numerical digit of the third column ('1','2','3','4' etc..) and store those variables in $1 and $2 variables inside a loop for every record.
Thanks for the quick reply...
It almost worked but may be little change needed here..
The input file have more than 3columns here..
Let me show you an example record:
awk '/OrdAcctCycChg/ {print $1,substr($3,length($3),1)}' inputfile | while read a b
do
echo $a #your first variable value
echo $b #your second variable value
done
can it be independent of the field string 'OrdAcctCycChg',the because the file contents may vary and not always the field will be OrdAcctCycChg.
Can you please help me in this case:(
Yeah it worked...Thankyou verymuch for the quick response:)
I have one more doubt..
Iam running a sql select command inside shell script and redirecting its output to a file.
is there any way to wait until the query completes (like wait command) its processing and redirecting the output to the file.
Because the code is trying to access the file before the query completion and am getting ambigous errors because of it>
Am pasting here the code for your reference.
Please provide me a way to get rid of this problem
sqlplus -s /nolog |&
print -p "connect $db_user/$db_pwd@$db_sid;"
print -p "SPOOL output.txt;"
while read var_ack_party_name
do
print -p "set pagesize 0 feedback off verify off heading off echo off linesize 100 \n"
print -p "select * from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and event_data_text like '%"$var_ack_party_name"%';"
done <./$1.txt
nawk '{if($2 ~ "^[a-zA-Z]"){print $1,substr($3,length($3),1)}}' ./output.txt | while read a b
sqlplus -s /nolog |&
print -p "connect $db_user/$db_pwd@$db_sid;"
print -p "SPOOL output.txt;"
while read var_ack_party_name
do
print -p "set pagesize 0 feedback off verify off heading off echo off linesize 100 \n"
print -p "select * from bus_event where ack_party_name like 'MOVE_USAGE_DAEMON%' and event_data_text like '%"$var_ack_party_name"%';"
done <./$1.txt
nawk '{if($2 ~ "^[a-zA-Z]"){print $1,substr($3,length($3),1)}}' ./output.txt | while read a b
the output.txt file contains the query output.
Before the query completion,the code is trying to access output.txt file and am getting cannot open ./output.txt file error.
Can we modify the code to wait for the query execution to get complete and output.txt file created here?
use sleep command to stop executing the script for a while so that output.txtwill be available to access.
done <./$1.txt
sleep 180 && echo " Waiting for the query execution..."
nawk '{if($2 ~ "^[a-zA-Z]"){print $1,substr($3,length($3),1)}}' ./output.txt | while read a b
Hi Rajesh,
1.Please try to give one filename instead of ./$1.txt
2.Please find out how long the query execution process takes time so that we need to set the Sleep time command.
3.Suspend the script using sleep for a while then execute the nawk or awk.