![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help with awk
Hi Guys,,
I am assigning a query result to a variable. variable=`db2 -x "select col1 from table1 | awk '{print $1}'` The problem is if i execute the above command without awk. I am getting an value. But if i execute with awk command, i am getting an error, saying A database connection does not exists. I want the awk command to be used. Please help me. Thanks for your help in advance, Magesh |
|
||||
|
Code:
variable=`db2 -x "select col1 from table1` how ever u can try somethng like this Code:
variable1=`db2 -x "select col1 from table1"`
variable=`echo "$variable1" | awk '{print $1}' `
|
|
||||
|
Code:
variable=`db2 -x "select col1 from table1 | awk '{print $1}'`
The problem is if i execute the above command without awk. I am getting an value.
I am sure that, Code:
variable=`db2 -x "select col1 from table1"` also wont return anything and ther is some issue with the data base connectvity. Because the next awk statemnt is nothng to do much other than priting. |
|
||||
|
correct panyam, i too thought so. When i execute it in the command line. i am getting the value. But when i put it in the script, the value is not getting assigned to the variable.
The code in the scripts is PREVIOUS_QTR=`db2 -x "SELECT statement"` PREVIOUS_QTRAPPLBTY= `echo "$PREVIOUS_QTR" | awk '{print $1}'` echo $PREVIOUS_QTRAPPLBTY in the verbose mode, i got this PREVIOUS_QTR= 200901 PREVIOUS_QTRAPPLBTY= `echo "$PREVIOUS_QTR" | awk '{print $1}'` + awk {print $1} + echo 200901 + 200901 + PREVIOUS_QTRAPPLBTY= genTmGapQTR.ksh[22]: 200901: not found. echo $PREVIOUS_QTRAPPLBTY + echo Please help me.. in this |
|
||||
|
Thanks dude.. it worked man..
|
| Sponsored Links | ||
|
|