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
MGD77INFO(1gmt) 					       Generic Mapping Tools						   MGD77INFO(1gmt)

NAME
mgd77info - Get information about MGD77[+] files SYNOPSIS
mgd77info NGDC-ids [ -C[m|e] ] [ -E[m|e] ] [ -Iignore ] [ -Mf[item]|r|e|h ] [ -L[v] ] [ -V ] DESCRIPTION
mgd77info reads <legid>.[mgd77|nc] files and produces a single record of information about each cruise specified. The information includes beginning and end times, total track distances in km, longitude and latitude range, and the total number of geophysical observations. Optionally, choose instead to see the original MGD77 header meta-data section or its individual members. If you need to know which tracks are crossing through a given region and what kinds of geophysical observations are available, consider using the x2sys tools to set up a tracks index data base (see x2sys_init for more information). NGDC-ids Can be one or more of five kinds of specifiers: 1) 8-character NGDC IDs, e.g., 01010083, JA010010etc., etc. 2) 2-character <agency> codes which will return all cruises from each agency. 3) 4-character <agency><vessel> codes, which will return all cruises from those vessels. 4) =<list>, where <list> is a table with NGDC IDs, one per line. 5) If nothing is specified we return all cruises in the data base. (See mgd77info -L for agency and vessel codes). The ".mgd77" or ".nc" extensions will automatically be appended, if needed (use -I to ignore certain file types). Cruise files will be looked for first in the current directory and second in all directories listed in $MGD77_HOME/mgd77_paths.txt [If $MGD77_HOME is not set it will default to $GMT_SHAREDIR/mgd77]. OPTIONS
No space between the option flag and the associated arguments. -C List abbreviations for all columns present in the MGD77[+] files. Append m or e to limit the display to the MGD77 standard or MGD77+ extended set only. -E Give a one-line summary for each cruise listed. -M List the meta-data (header) and (if present) the MGD77+ history for each cruise. Append f for a formatted display. This will list individual parameters and their values, one entry per output line, in a format that can be searched using standard UNIX text tools. Alternatively, append the name of a particular parameter (you only need to give enough characters - starting at the beginning - to uniquely identify the item). Give - to display the list of all parameter names. You may also specify the number of a parameter. For the raw, punchcard-formatted MGD77 original header block, append r instead. For the MGD77+ E77 status, append e instead. Finally, for the MGD77+ history, append h instead. -I Ignore certain data file formats from consideration. Append a|c|t to ignore MGD77 ASCII, MGD77+ netCDF, or plain tab-separated ASCII table files, respectively. The option may be repeated to ignore more than one format. [Default ignores none]. -L No cruise information is listed. Instead, we just display a list of the GEODAS institution 2-character codes and their names. Optionally, append v to also display the vessels and their 4-character codes for each institution. The following is the list of institutions:(01) LAMONT (LDEO), (02) WOODS HOLE O.I., (03) NOAA, (04) US ARMY, (05) NEW ZEALAND, (06) US GEOL. SURVEY, (07) OREGON ST. UNIV, (08) U.HAWAII SOEST, (09) US NAVY, (10) UNIV OF TEXAS, (11) RICE UNIV., (12) CANADA, (13) UNIV OF CONN., (14) U.MIAMI (RSMAS), (15) SCRIPPS INST.OC, (16) CHINA, (17) U RHODE ISLAND, (18) DUKE UNIVERSITY, (19) UNITED KINGDOM, (20) U.WASHINGTON, (22) WESTERN GEO- PHY., (23) TEXAS A&M UNIV., (24) AUSTRALIA, (25) MONACO, (29) RUSSIA, (30) SPAIN, (35) NIMA, (58) NETHERLANDS, (60) MIN MGMT SVC, (63) ISRAEL, (67) FRANCE, (71) SOUTH AFRICA, (75) US COAST GUARD, (76) BRAZIL, (77) INT. GRAV. BUR, (83) GERMANY, (84) ORSTOM NEW CAL, (86) CUBA, (87) ARGENTINA, (88) US NSF, (89) INDIA, (90) PORTUGAL, (92) FINLAND, (93) CHILE, (J1) HYDR DEPT JAPAN, (J2) GEOL SRVY JAPAN, (J4) UNIV TOKYO, (J5) KOBE UNIV, (J7) UNIV OF RYUKYUS, (J8) J.O.D.C. JAPAN, (J9) CHIBA UNIV, (JA) INST.POLAR RES., (ZZ) INST NOT CODED. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. EXAMPLES
To get one-line summary information about the cruises 01010047.mgd77 and 01010008.mgd77, try mgd77info 01010047 01010008 -E > listing.lis To see the original raw MGD77 header meta-data for cruise 01010047.mgd77, run mgd77info 01010047 -Mr To determine all the parameters related to Gravity during cruise 01010047.mgd77, run mgd77info 01010047 -Mf | grep Gravity To determine the Magnetic sampling rate used during cruise 01010047.mgd77, run mgd77info 01010047 -MfMagnetics_Sampling_Rate To see all the columns that the MGD77+ cruise 01010047.nc contains, run mgd77info 01010047 -C To see the E77 status of all MGD77+ cruises collected by the University of Hawaii, run mgd77info 08 -Ia -Me SEE ALSO
mgd77list(1), mgd77manage(1), mgd77path(1), mgd77track(1) x2sys_init(1) REFERENCES
Wessel, P., and W. H. F. Smith, 2011, The Generic Mapping Tools (GMT) version 4.5.7 Technical Reference & Cookbook, SOEST/NOAA. Wessel, P., and W. H. F. Smith, 1998, New, Improved Version of Generic Mapping Tools Released, EOS Trans., AGU, 79(47), p. 579. Wessel, P., and W. H. F. Smith, 1995, New Version of the Generic Mapping Tools Released, EOS Trans., AGU, 76(33), p. 329. Wessel, P., and W. H. F. Smith, 1995, New Version of the Generic Mapping Tools Released, http://www.agu.org/eos_elec/95154e.html, Copyright 1995 by the American Geophysical Union. Wessel, P., and W. H. F. Smith, 1991, Free Software Helps Map and Display Data, EOS Trans., AGU, 72(41), p. 441. The Marine Geophysical Data Exchange Format - "MGD77", see http://www.ngdc.noaa.gov/mgg/dat/geodas/docs/mgd77.txt GMT 4.5.7 15 Jul 2011 MGD77INFO(1gmt)
All times are GMT -4. The time now is 01:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy