Sponsored Content
Full Discussion: If Then Else Logic
Top Forums UNIX for Dummies Questions & Answers If Then Else Logic Post 302146772 by jadionne on Thursday 22nd of November 2007 07:06:35 AM
Old 11-22-2007
Quote:
Originally Posted by bakunin
Your problem is you are looking in the wrong place. ;-)

The shell construct "if [ ...] ; then" is utilizing a command external to the shell: /usr/bin/test. In fact "[....]" is just an alternative way to write "test ...." and branch on the errorlevel (return value) of this command.

You have the following (basic) options in test, more to be found on the manpage of test:

(for the following we assume x=5 and y=10)
-gt "greater then" compare (integer) values: test $x -gt $y => returns FALSE
-ge "greater or equal"
-lt "lower then"
-le "lower equal"
-eq "equal"
-ne "not equal"

-a logical AND. Example: test "$x -gt 0 -a $y -ge x" => returns TRUE
-o logical OR. Analogous to above

\(...\) grouping. Example: test "\( $x -gt 0 \) -a \( $y -gt $x -o $y -gt 0 \)"

-n non-zero TRUE if a string is not empty
-z zero TRUE if a string is empty ("")

I hope this helps.

bakunin


This looks a bit more streight forward to me...but again do you have a detailed link that can clear up some questions for me.

For example
Code:
test $x -gt $y => returns FALSE

what is the => representing here?
 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

Need help in logic

I have big large snapshot file which contains every process start time and end time. One server snapshot contains many Application handle. My task is to identify the process id for which the end time is not there or empty also if the completion time is not on the same date then I need to kill. ... (6 Replies)
Discussion started by: senthilkumar_ak
6 Replies
SQL::Statement::Term(3pm)				User Contributed Perl Documentation				 SQL::Statement::Term(3pm)

NAME
SQL::Statement::Term - base class for all terms SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::Term->new( $owner ); # access the value of that term $term->value( $eval ); DESCRIPTION
SQL::Statement::Term is an abstract base class providing the interface for all terms. INHERITANCE
SQL::Statement::Term METHODS
new Instantiates new term and stores a weak reference to the owner. value Abstract method which will return the value of the term. Must be overridden by derived classes. DESTROY Destroys the term and undefines the weak reference to the owner. NAME
SQL::Statement::ConstantTerm - term for constant values SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::ConstantTerm->new( $owner, 'foo' ); # access the value of that term - returns 'foo' $term->value( $eval ); DESCRIPTION
SQL::Statement::ConstantTerm implements a term which will always return the same constant value. INHERITANCE
SQL::Statement::ConstantTerm ISA SQL::Statement::Term METHODS
new Instantiates new term and stores the constant to deliver and a weak reference to the owner. value Returns the specified constant. NAME
SQL::Statement::ColumnValue - term for column values SYNOPSIS
# create a term with an SQL::Statement object as owner my $term = SQL::Statement::ColumnValue->new( $owner, 'id' ); # access the value of that term - returns the value of the column 'id' # of the currently active row in $eval $term->value( $eval ); DESCRIPTION
SQL::Statement::ColumnValue implements a term which will return the specified column of the active row. INHERITANCE
SQL::Statement::ColumnValue ISA SQL::Statement::Term METHODS
new Instantiates new term and stores the column name to deliver and a weak reference to the owner. value Returns the specified column value. AUTHOR AND COPYRIGHT
Copyright (c) 2009,2010 by Jens Rehsack: rehsackATcpan.org All rights reserved. You may distribute this module under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.10.1 2011-02-01 SQL::Statement::Term(3pm)
All times are GMT -4. The time now is 11:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy