Hi Guys,
I need to check whether the last column is RP, If so, then i have to second column and pass it to a select statement as sonid and fetch the value to a variable and run it. This has to be done till the last column is RW.
value Fatherid sonid topid Rrecord
45.000000 53701179 53701399 115390862 RP
96.400000 77748483 77747303 115369623 RP
100.000000 115373349 52628463 115373341 RP
100.000000 115373353 52628463 115373341 RP
100.000000 115373470 52628463 115373462 RP
100.000000 115373474 52628463 115373462 RP
I am having a hard time in reading the last column from the file.
Guys, help me out..
Thanks for the help in advance,
Regards,
Magesh
Below command can give you lines ending with RP
something like:
# nawk '/RP$/{print $2}' infile
53701179
77748483
115373349
115373353
115373470
115373474
should get you started in the right direction....
But actually i want to get the value field into one variable, sonid into another variable and father id into another variable for each row.. so that i can create the update statements using them.. How to do it for each line by line??
Something like this
grep ".*RP$" file|cut -d' ' -f2-4|while read Fatherid sonid topid
do
echo $Fatherid $sonid $topid
done
i also just figured it.. i am just goin to update it in the forum..Btw this forum rockss..
---------- Post updated at 05:06 PM ---------- Previous update was at 04:53 PM ----------
Guys i am trying to concantenate the variable taken to the select statement, But it is throwing an error..
This is the code i tried..
if [[$a = '01']] ; then
echo "select * from trd.trd_categroy where ctreadcomp='$a' withur;" > sql.out
fi
can you suggest me where i am going wrong?
some space missing
if [[ $a = '01' ]] ; then
echo "select * from trd.trd_categroy where ctreadcomp='$a' withur;" > sql.out
fi
if [[ "$a" = "01" ]] ; then
You the man.. i tried the below code.. But yours is compact.. i ll try urs itslf
if [ $a -eq '01' ] ; then
select="select * from trd.trd_categroy where ctreadcomp='";
end="' with ur;";
update_statement="$select$a$end";
echo $update_statement;
exit;
fi