|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
The script i am using is as follows:
CONT="TRUE" echo "Waiting to Get Scheduled" while [ "$CONT" = "TRUE" ] do if [ ! -f $DSSDATW5/W5DW_RUNNING.out ] then break else if ["`wc -l $DSSDATW5/W5DW_RUNNING.out | cut -c1-8`" -eq 0 ] then break else sleep 100 continue fi fi done first part look if file exists, if yes then checks for word count. But when it checks for word count it gives me error at line of comparison with word count DEL_FILE_W5DW_DENORM_FINAL[22]: [ 2: not found. where DEL_FILE_W5DW_DENORM_FINAL is the job name where the code exists. can any one help to understand whats going wrong. |
|
#2
|
|||
|
|||
|
Ack .. nasty, nasty, nasty!!!!
Code:
["`wc -l $DSSDATW5/W5DW_RUNNING.out | cut -c1-8`" -eq 0 ] First off, that is comparing a string (you have enclosed the wc command in quotes) to a numeric (the 0) with the numeric equality testing operand (the -eq) and you are also extracting the first 8 characters of the returned result from the wc, which is not what you want. What you want is: Code:
[`wc -l $DSSDATW5/W5DW_RUNNING.out | awk '{print $1}'` -eq 0 ]
which will, I hope!, do a wc and then just pass on to the test the first field which should be the count. And I am assuming that the variable $DSSDATW5 is defined elsewhere? |
|
#3
|
|||
|
|||
|
The solution that you have given worked , with one more change that was specific to my logic.
if [`wc -w $DSSDATW5/W5DW_RUNNING.out | awk '{print $1}'` -eq 0 ] and even this works fine. [`wc -w $DSSDATW5/W5DW_RUNNING.out | cut -c0-8` -eq 0 ] Even this can be a solution. Thanks SimonJM |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Using word count in file for comparison. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|