![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EOF checking the below | ramkrix | High Level Programming | 10 | 03-11-2008 01:43 AM |
| checking uid | filthymonk | Shell Programming and Scripting | 7 | 07-19-2007 11:40 PM |
| Checking cp progress | MarGur | UNIX for Dummies Questions & Answers | 0 | 05-15-2007 05:13 PM |
| Checking for PXE | maestro@altiris | SUN Solaris | 5 | 05-25-2004 01:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
if then for non-zero
You can do it simpler, but I am assuming that you might have several things to do when a non-zero is found.
This is looking for the last one line of the file; knowing that the value will be on that line. x=$(tail -1 sqlplus.out) echo $x if [ $x -ne 0 ] then echo "You have found a non-zero value" fi |
|
|||||
|
Quote:
Code:
if [ `tail -1 sqlplus.out` -ne 0 ] ; then echo "You have found a non-zero value" ; fi |
|
|||||
|
without the back ticks it didn't work, so thanks go to the Smiling Dragon for helping out and thanks joeyg for the attempt. However, it still doesn't work, I get the following as a result: Code:
" near 0wn operator in arithmetic expression "0 There is no quotation mark present in the sqlplus.out file, though I decided to vi the file and found that there is a ^M character at the end of each line. I should let you know that this is a unix emulator on a windows server. Another thing to mention is that the result in the sqlplus.out file does not start at the first character, sqlplus right justifies the value with the field header - for whatever reason the unix.com forum interface put it to the left. Thanks again for the assistance! |
|
||||
|
just a side note what DB are using to get the data out of? I know if you use certain operaters in DB2 you can cut out all the unneeded stuff like column headers I.E. Code:
db2 -x "select * from your.table" If you can get your DB to cut out all the crap then all you will have to worrie about is comparing the values and you can throw out the "tail" command. Just a thought. Jim |
|
|||||
|
Quote:
Code:
if `tail -1 sqlplus.out | egrep '[1-9]'` ; then ... |
|
|||||
|
Thanks!
While I am sure your solution works perfectly, I was able to work around the problem by changing my SQL that produces the difference between last id and max id and output 'true' if there is a difference. Now I just need to grep on true from the sqlplus.out file and that satisfies the condition. As always unix.com delivers, in my case not a final solution, but helpful hints to get me there. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|