Sponsored Content
Full Discussion: Condition problem
Top Forums Shell Programming and Scripting Condition problem Post 302972538 by kshji on Friday 6th of May 2016 12:29:58 PM
Old 05-06-2016
Maybe this example helps use to make comparing little easier in shell. You can add breaks as you like.
Code:
for file in *.txt
do
    stat="DEPTH"
    while IFS="," read f1 f2 DEPT SDEPT rest
    do
        flag="DEPTH"
        ## between ((   and ))   you can use syntax same as like in C or ...
        ((   ( DEPT != 888 )  && ( DEPT !=0 )   ))  && flag="C1"    # && break # if like to break
       # if the 3rd column contains 55, 16, 76 and 4th column = 888 or 0 then it's the same as by CLASS
       # so write rule as it has been written:
         ((  ( DEPT == 55 || DEPT == 16 || DEPT == 76 ) && ( SDEPT == 888 || SDEPT == 0 )  )) && flag="C2"
       # if the 3rd column contains 55, 16, 76 and 4th column not equal 888 or 0 then it's the same as by CLASS
       # so write rule as it has been written:
         ((  ( DEPT == 55 || DEPT == 16 || DEPT == 76 ) && ( SDEPT != 888 && SDEPT != 0 )  )) && flag="C3"
        echo "      $flag - $f1 $f2 d:$DEPT sd:$SDEPT $rest"
        [ "$flag" != "DEPTH" ] && stat="CLASS"
    done < $file
    echo "$file - $stat"
done

(( ( DEPT != 888 ) && ( DEPT !=0 ) )) && flag="CLASS"
is same as
Code:
if ((   ( DEPT != 888 )  && ( DEPT !=0)   ))  
then
   flag="CLASS"
fi


Last edited by kshji; 05-07-2016 at 03:48 AM..
This User Gave Thanks to kshji For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If condition problem

Hi Guys, I want to use if conition for my script. Before I used it tried it with some small test scripts. But it was not succeeded. My script and screen output as follows, Script: echo 'Do you think Yes or No (y/n) : ' read ans echo You input anser as $ans ans1=y if ( $ans == $ans1... (5 Replies)
Discussion started by: maheshsri
5 Replies

2. Shell Programming and Scripting

problem with if condition

hi, :) pls consider the following if statement if //g') ] then ........ else ....... when i execute the script i am getting the following error '(' unexpected I am not able to find the mistake. could anybody tell where i did mistake. cheers RRK (13 Replies)
Discussion started by: ravi raj kumar
13 Replies

3. Shell Programming and Scripting

problem in if condition

hi, actully i need the belp for the below. host_list=" Host1 host2 host3 host4 " n=`hostname` i need to put the condition like the below if n is among the host mention in the host_list if then #some stugg else # some other stuff fi (1 Reply)
Discussion started by: mail2sant
1 Replies

4. Shell Programming and Scripting

problem in if then else condition

Hi , I am trying the following simple script . But it is always giving 1 output. Dont know why #!/bin/sh find . -name "a.log" if ; then echo "1" else echo "0" fi Kindly advice. it is giving 1 output even when the a.log file is not there (26 Replies)
Discussion started by: himvat
26 Replies

5. Shell Programming and Scripting

Problem in using AND OR condition together

a=rhino b=crocodil c=testsc if && "$c" = testsc ] then echo "Test #5 succeeds." else echo "Test #5 fails." fi i need to test or condition before check the output with AND condition. ur help is much appreciated... (11 Replies)
Discussion started by: gokulraj23
11 Replies

6. Shell Programming and Scripting

Problem in if condition

Hi all, I have task to delete two different files from all file system. one is core file & other is old file. i can delete core file but for old file i have to mv in different location. i wrote a script but it is not working. i have a two variables in this script first one is delcnt &... (6 Replies)
Discussion started by: dravi_laxmi
6 Replies

7. Shell Programming and Scripting

If condition problem

Hi, I need to use if condition for search a file pattern on a particular location. cd $file_Path if || then do this else do that fi Can someone help me with the if part, how i can put those conditions? make sure format should be *.file* and *.file file is a keyword which i... (5 Replies)
Discussion started by: amit.mathur08
5 Replies

8. Shell Programming and Scripting

Problem with IF condition .

Hi i am writing a script where i am running , 5 scripts together in 1 script . Now what i want is when these 5 scripts run completely , i should execute some other commands like i have compile the data etc. I have have 5 echo statements at the end of all those scripts . Like echo "1 is done" in... (1 Reply)
Discussion started by: honey26
1 Replies

9. Shell Programming and Scripting

If condition problem

Hi All, I am using below if condition to check whether null is passed as a parameter to the program if or ; then echo "ABC">>$FILE else echo "CDF">>$FILE fi However it is saying me null=null command not found . Please help me with this (9 Replies)
Discussion started by: Hypesslearner
9 Replies
DROP OPERATOR 
CLASS(7) SQL Commands DROP OPERATOR CLASS(7) NAME
DROP OPERATOR CLASS - remove an operator class SYNOPSIS
DROP OPERATOR CLASS [ IF EXISTS ] name USING index_method [ CASCADE | RESTRICT ] DESCRIPTION
DROP OPERATOR CLASS drops an existing operator class. To execute this command you must be the owner of the operator class. DROP OPERATOR CLASS does not drop any of the operators or functions referenced by the class. If there are any indexes depending on the operator class, you will need to specify CASCADE for the drop to complete. PARAMETERS
IF EXISTS Do not throw an error if the operator class does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing operator class. index_method The name of the index access method the operator class is for. CASCADE Automatically drop objects that depend on the operator class. RESTRICT Refuse to drop the operator class if any objects depend on it. This is the default. NOTES
DROP OPERATOR CLASS will not drop the operator family containing the class, even if there is nothing else left in the family (in particu- lar, in the case where the family was implicitly created by CREATE OPERATOR CLASS). An empty operator family is harmless, but for the sake of tidiness you might wish to remove the family with DROP OPERATOR FAMILY; or perhaps better, use DROP OPERATOR FAMILY in the first place. EXAMPLES
Remove the B-tree operator class widget_ops: DROP OPERATOR CLASS widget_ops USING btree; This command will not succeed if there are any existing indexes that use the operator class. Add CASCADE to drop such indexes along with the operator class. COMPATIBILITY
There is no DROP OPERATOR CLASS statement in the SQL standard. SEE ALSO
ALTER OPERATOR CLASS [alter_operator_class(7)], CREATE OPERATOR CLASS [create_operator_class(7)], DROP OPERATOR FAMILY [drop_operator_fam- ily(7)] SQL - Language Statements 2010-05-14 DROP OPERATOR CLASS(7)
All times are GMT -4. The time now is 12:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy