Sponsored Content
Full Discussion: IF OR with two conditions
Top Forums Shell Programming and Scripting IF OR with two conditions Post 302474765 by Flavius on Thursday 25th of November 2010 10:15:33 AM
Old 11-25-2010
IF OR with two conditions

I have this IF working fine, testing if a char is a digit:

Code:
      if [ $_CHAR -eq $_CHAR 2>/dev/null ]; then
         _VALUE=$_VALUE$_CHAR
      else
         _ISDIGIT="false"
      fi

Then I add a second condition to test if the char is either a digit or a *

Code:
      if [[ $_CHAR -eq $_CHAR 2>/dev/null || $_CHAR == "*" ]]; then
         _VALUE=$_VALUE$_CHAR
      else
         _ISDIGIT="false"
      fi

I get this:

Code:
./statusSIGTRAN_TSP5.sh: line 35: syntax error in conditional expression
./statusSIGTRAN_TSP5.sh: line 35: syntax error near `2>'
./statusSIGTRAN_TSP5.sh: line 35: `      if [[ $_CHAR -eq $_CHAR 2>/dev/null || $_CHAR == "*" ]]; then'

What's wrong?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

2 or more if conditions

Hello, I have a file as follows: col no:1 2 3 4 5 6 7 8 9 10 11 a 4 226 226 ch:95024048-95027592, 1y224 of 3545 223 224 ident b 53 235 235 ch:148398-148401255, 1y184 of 3187 180 186 ident awk... (3 Replies)
Discussion started by: dr_sabz
3 Replies

2. Shell Programming and Scripting

multiple if conditions

Guys, Im trying to have a script that evaluates multiple conditions : test.sh: if then echo "host $1" else if then echo "host $1" else echo $1 not valid exit 1 fi when I do ./test.sh brazil1 I get: (4 Replies)
Discussion started by: bashshadow1979
4 Replies

3. Shell Programming and Scripting

conditions

./script 89 The script will extract the last digit of the input parameter. example, that is 4. This will be compared to the last digit of the current day of the month ( like day 14; that is 4). A message will displayed on the screen indicating if the digits are the same or not. (1 Reply)
Discussion started by: singh is king
1 Replies

4. Shell Programming and Scripting

Help regarding multiple conditions

Hi All, I am new to shell scripting. Can any one say what is wrong in this if statement, that uses multiple conditions if then *************** else if ( -z $pcs && "$night_time_calc" > "$night_time" ) then ******************************** ... (4 Replies)
Discussion started by: ssenthilkumar
4 Replies

5. Shell Programming and Scripting

While with three conditions

Currently this is what I am trying while || && ]; do I want to continue if the first condition or both the second and third are true but I am getting a too many arguments error. Can someone help me out? (5 Replies)
Discussion started by: whdr02
5 Replies

6. Shell Programming and Scripting

If conditions need

Dear Expert, Below code is for to take the backup of database by daily time stamp. I need vital help to make my script automatic sending me email if it sucess or fail. echo on @REM Seamonkey's quick date batch (MMDDYYYY format) @REM Setups %date variable @REM First parses month, day, and... (6 Replies)
Discussion started by: Alone
6 Replies

7. Shell Programming and Scripting

Zenity, While, and Conditions

All, I'm having fighting a losing battle with what I though would be simple. My goal is this: Show a zenity progress or info dialog until the system obtains an ip address, then close the dialog and continue through the rest of the script. Right now I've got the following: ip=`ifconfig |... (2 Replies)
Discussion started by: timbrammer91091
2 Replies

8. Shell Programming and Scripting

Errors in if conditions with to many OR conditions

Hi ALL I have a script where in i need to check for several values in if conditons but when i execute the script it throws error such as "TOO MANY ARGUMENTS" if then msg="BM VAR Issue :: bmaRequestVAR=$bmaRequestVAR , nltBMVAR=$nltBMVAR , bmaResponseVAR=$bmaResponseVAR ,... (10 Replies)
Discussion started by: nikhil jain
10 Replies

9. Shell Programming and Scripting

Errors in if conditions.....

#if if then echo $varNO >> AgriN.csv fi done < data The above script throws error such as integer expression expected. How do i rectify that?? (4 Replies)
Discussion started by: nikhil jain
4 Replies

10. Shell Programming and Scripting

Conditions in if

I'm using the below one.. #!/bin/ksh File=$3 if ; then echo "Script" elif ] ;then echo "Passed k or f option" else "Please check the Input passed" fi Command line argument is "k" or -f and file is exist then... (3 Replies)
Discussion started by: Roozo
3 Replies
TAP::Parser::Grammar(3pm)				 Perl Programmers Reference Guide				 TAP::Parser::Grammar(3pm)

NAME
TAP::Parser::Grammar - A grammar for the Test Anything Protocol. VERSION
Version 3.26 SYNOPSIS
use TAP::Parser::Grammar; my $grammar = $self->make_grammar({ iterator => $tap_parser_iterator, parser => $tap_parser, version => 12, }); my $result = $grammar->tokenize; DESCRIPTION
"TAP::Parser::Grammar" tokenizes lines from a TAP::Parser::Iterator and constructs TAP::Parser::Result subclasses to represent the tokens. Do not attempt to use this class directly. It won't make sense. It's mainly here to ensure that we will be able to have pluggable grammars when TAP is expanded at some future date (plus, this stuff was really cluttering the parser). METHODS
Class Methods "new" my $grammar = TAP::Parser::Grammar->new({ iterator => $iterator, parser => $parser, version => $version, }); Returns TAP::Parser grammar object that will parse the TAP stream from the specified iterator. Both "iterator" and "parser" are required arguments. If "version" is not set it defaults to 12 (see "set_version" for more details). Instance Methods "set_version" $grammar->set_version(13); Tell the grammar which TAP syntax version to support. The lowest supported version is 12. Although 'TAP version' isn't valid version 12 syntax it is accepted so that higher version numbers may be parsed. "tokenize" my $token = $grammar->tokenize; This method will return a TAP::Parser::Result object representing the current line of TAP. "token_types" my @types = $grammar->token_types; Returns the different types of tokens which this grammar can parse. "syntax_for" my $syntax = $grammar->syntax_for($token_type); Returns a pre-compiled regular expression which will match a chunk of TAP corresponding to the token type. For example (not that you should really pay attention to this, "$grammar->syntax_for('comment')" will return "qr/^#(.*)/". "handler_for" my $handler = $grammar->handler_for($token_type); Returns a code reference which, when passed an appropriate line of TAP, returns the lexed token corresponding to that line. As a result, the basic TAP parsing loop looks similar to the following: my @tokens; my $grammar = TAP::Grammar->new; LINE: while ( defined( my $line = $parser->_next_chunk_of_tap ) ) { for my $type ( $grammar->token_types ) { my $syntax = $grammar->syntax_for($type); if ( $line =~ $syntax ) { my $handler = $grammar->handler_for($type); push @tokens => $grammar->$handler($line); next LINE; } } push @tokens => $grammar->_make_unknown_token($line); } TAP GRAMMAR
NOTE: This grammar is slightly out of date. There's still some discussion about it and a new one will be provided when we have things better defined. The TAP::Parser does not use a formal grammar because TAP is essentially a stream-based protocol. In fact, it's quite legal to have an infinite stream. For the same reason that we don't apply regexes to streams, we're not using a formal grammar here. Instead, we parse the TAP in lines. For purposes for forward compatibility, any result which does not match the following grammar is currently referred to as TAP::Parser::Result::Unknown. It is not a parse error. A formal grammar would look similar to the following: (* For the time being, I'm cheating on the EBNF by allowing certain terms to be defined by POSIX character classes by using the following syntax: digit ::= [:digit:] As far as I am aware, that's not valid EBNF. Sue me. I didn't know how to write "char" otherwise (Unicode issues). Suggestions welcome. *) tap ::= version? { comment | unknown } leading_plan lines | lines trailing_plan {comment} version ::= 'TAP version ' positiveInteger {positiveInteger} " " leading_plan ::= plan skip_directive? " " trailing_plan ::= plan " " plan ::= '1..' nonNegativeInteger lines ::= line {line} line ::= (comment | test | unknown | bailout ) " " test ::= status positiveInteger? description? directive? status ::= 'not '? 'ok ' description ::= (character - (digit | '#')) {character - '#'} directive ::= todo_directive | skip_directive todo_directive ::= hash_mark 'TODO' ' ' {character} skip_directive ::= hash_mark 'SKIP' ' ' {character} comment ::= hash_mark {character} hash_mark ::= '#' {' '} bailout ::= 'Bail out!' {character} unknown ::= { (character - " ") } (* POSIX character classes and other terminals *) digit ::= [:digit:] character ::= ([:print:] - " ") positiveInteger ::= ( digit - '0' ) {digit} nonNegativeInteger ::= digit {digit} SUBCLASSING
Please see "SUBCLASSING" in TAP::Parser for a subclassing overview. If you really want to subclass TAP::Parser's grammar the best thing to do is read through the code. There's no easy way of summarizing it here. SEE ALSO
TAP::Object, TAP::Parser, TAP::Parser::Iterator, TAP::Parser::Result, perl v5.18.2 2014-01-06 TAP::Parser::Grammar(3pm)
All times are GMT -4. The time now is 12:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy