![]() |
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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script required to get a required info from file. Pls. help me. | ntgobinath | Shell Programming and Scripting | 2 | 05-31-2008 08:34 AM |
| search for the contents in many file and print that file using shell script | cdfd123 | Shell Programming and Scripting | 3 | 10-07-2007 10:17 PM |
| Creating file contents using contents of another file | ReV | Shell Programming and Scripting | 21 | 02-24-2006 10:25 AM |
| Reading specific contents from a file and appending it to another file | dnicky | Shell Programming and Scripting | 5 | 10-04-2005 05:45 AM |
| ls contents of a file | douknownam | Shell Programming and Scripting | 7 | 06-14-2004 09:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have created three SQL scripts that are run by one central script. What I need to do is verify the output file from the three SQL scripts(KSH Scripts) is worth emailing. This I would like to do by verifiying the contents of the result file.
The contrlooing script creates the result file then the SQL scripts append to it from then on until the opreation completes. For instance I have ecohed a line for each instance of the SQL script being run into the result file. So there are three lines minimum in the result file, what I would like to do is count the lines if ther are more that three line email the file, if ther are less just delete the file. I am having trouble assinging a varialbe to the lines counted in the result file. I have tried; wc -l result_file let line_c=$a-$b if [ lin_c -le 3 ]; then Email file else delete file fi HELP!!!!! |
|
||||
|
The result was not correct I have had to adjust the code to get the correct response but am unable to.
fil_len=`wc -l < input_file` if [ fil_len > 3 ]; then email file elif [ file_len < 3 ]; then delete empty file fi The test statement will not accept the value from fil_len, I have output to the screen to see if it is valid and it gives a number but not sure if it is char or numeric. The output looks like this; 9 No matter what I do it will only select the first part of the statement as true. Regardless of the lines in the file. All in a Korn Shell (KSH) sorry for the premature elation!!!! (hair trigger trouble you know) |
|
||||
|
The only thing I had not tried was the
if ((fil_len > 3)) then I had Tried if [ $fil_len > 3 ]; then if [ "$fil_len" > 3 ]; then if [ "$fil_len" > "3" ]; then if [ "fil_len" > 3 ]; then just about every permutation you could thing of......... except if ((fil_len > 3)) then Which works successfully (tested fully I might add) Thanks again for the insight how to resolve this one. |
|
|||||
|
To do numeric tests in either a bracket or double bracket form of if statement, you must use -gt like this...
if [ $fil_len -gt 3 ] ; then When you use > in that style of if statement you are testing which string comes first in straight ascii sort. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|