Sponsored Content
Full Discussion: If with set operators
Top Forums UNIX for Advanced & Expert Users If with set operators Post 302189278 by Khoomfire on Friday 25th of April 2008 10:54:25 AM
Old 04-25-2008
If with set operators

Hi guys, I'm trying to run more than one "if" condition at once. What I want is something like

if [[ $a = 1 ]] or [[ $b = 2 ]] or [[ $c = 3 ]]; then
...


I can't remember the syntax for using this or/and set operators. Can someone please assist/ jog my memory?

thanks
Khoom
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

bitwise operators

can anybody write a program to divide a number by another number using bitwise operators (9 Replies)
Discussion started by: areef4u
9 Replies

2. UNIX for Dummies Questions & Answers

Operators

I am trying to understand Does the following: {tmp+=$10} Mean take $10 and add them all up and call it tmp thanks! (2 Replies)
Discussion started by: llsmr777
2 Replies

3. Shell Programming and Scripting

Operators

I really don't know the meaning of these operators. Could someone explain the meanings so I can make my test for today? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

4. Homework & Coursework Questions

Operators

I really don't know the meaning of these operators. Could someone explain the meanings? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

5. Shell Programming and Scripting

BASH - set specific user variable via string operators

Apologies for the utter triviality of this question, but we all have to start somewhere! I've also tried searching but this question is pretty vague so I didn't (a) really know what to search for or (b) get many relevant hits to what I did search for. Anyway, I'm in the process of self-teaching... (1 Reply)
Discussion started by: u5j84
1 Replies

6. Shell Programming and Scripting

Array operators

Hi Lets say I have two arrays: VAR_1 = "File_A" "File_B" "File_C" "File_D" VAR_2 = "File_A" "File_D" Is there a simple command to get the difference of these list, i.e. VAR_1_2 = "File_B" "File_C" or do I have to write a script and loop through all elements and compare them one by one? ... (1 Reply)
Discussion started by: Wernfried
1 Replies

7. Shell Programming and Scripting

operators in if loop

Hi all, I have a variable which is having the value like below, $ echo ${p} 8 15 22 30 $ My requirement is that the variable should return true when it contains only one number like below, $ echo ${p} 15 $ Otherwise, it should return false if it contains more than one number. I... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

8. Programming

Combining Operators

Hey everyone, I'm really getting into learning C, but as I look at more advanced example code, I see things like if (!*variable1) blah blah blah... and variable2 ^= *(variable1++); my question is, when you have a combination of two operators, like !*. The ! means 'not' and the *... (2 Replies)
Discussion started by: Lost in Cyberia
2 Replies

9. UNIX for Beginners Questions & Answers

Bash -o -v -R operators

I do not know the use of the -o -v -R operators. This is what the info says and I am confused of what optname and varname mean, are they just normal variable? -o optname True if the shell option optname is enabled. See the list of options under the ... (6 Replies)
Discussion started by: kristinu
6 Replies
Perl6::Junction(3)					User Contributed Perl Documentation					Perl6::Junction(3)

NAME
Perl6::Junction - Perl6 style Junction operators in Perl5. SYNOPSIS
use Perl6::Junction qw/ all any none one /; if (any(@grant) eq 'su') { ... } if (all($foo, $bar) >= 10) { ... } if (qr/^d+$/ == all(@answers)) { ... } if (all(@input) <= @limits) { ... } if (none(@pass) eq 'password') { ... } if (one(@answer) == 42) { ... } DESCRIPTION
This is a lightweight module which provides 'Junction' operators, the most commonly used being "any" and "all". Inspired by the Perl6 design docs, <http://dev.perl.org/perl6/doc/design/exe/E06.html>. Provides a limited subset of the functionality of Quantum::Superpositions, see "SEE ALSO" for comment. Notice in the "SYNOPSIS" above, that if you want to match against a regular expression, you must use "==" or "!=". Not "=~" or "!~". You must also use a regex object, such as "qr/d/", not a plain regex such as "/d/". SUBROUTINES
all() Returns an object which overloads the following operators: '<', '<=', '>', '>=', '==', '!=', 'lt', 'le', 'gt', 'ge', 'eq', 'ne', Returns true only if all arguments test true according to the operator used. any() Returns an object which overloads the following operators: '<', '<=', '>', '>=', '==', '!=', 'lt', 'le', 'gt', 'ge', 'eq', 'ne', Returns true if any argument tests true according to the operator used. none() Returns an object which overloads the following operators: '<', '<=', '>', '>=', '==', '!=', 'lt', 'le', 'gt', 'ge', 'eq', 'ne', Returns true only if no argument tests true according to the operator used. one() Returns an object which overloads the following operators: '<', '<=', '>', '>=', '==', '!=', 'lt', 'le', 'gt', 'ge', 'eq', 'ne', Returns true only if one and only one argument tests true according to the operator used. ALTERING JUNCTIONS
You cannot alter junctions. Instead, you can create new junctions out of old junctions. You can do this by calling the "values" method on a junction. my $numbers = any(qw/1 2 3 4 5/); print $numbers == 3 ? 'Yes' : 'No'; # Yes $numbers = any( grep { $_ != 3 } $numbers->values ); print $numbers == 3 ? 'Yes' : 'No'; # No EXPORT
'all', 'any', 'none', 'one', as requested. All subroutines can be called by its fully qualified name, if you don't want to export them. use Perl6::Junction; if (Perl6::Junction::any( @questions )) { ... } WARNING
When comparing against a regular expression, you must remember to use a regular expression object: "qr/d/" Not "/d/". You must also use either "==" or "!=". This is because "=~" and "!~" cannot be overriden. TO DO
Add overloading for arithmetic operators, such that this works: $result = any(2,3,4) * 2; if ($result == 8) {...} SUPPORT
/ BUGS Submit to the CPAN bugtracker <http://rt.cpan.org> SEE ALSO
Quantum::Superpositions provides the same functionality as this, and more. However, this module provides this limited functionality at a much greater runtime speed, with my benchmarks showing between 500% and 6000% improvment. <http://dev.perl.org/perl6/doc/design/exe/E06.html> - "The Wonderful World of Junctions". AUTHOR
Carl Franks ACKNOWLEDGEMENTS
Thanks to "Curtis "Ovid" Poe" for the "ALTERING JUNCTIONS" changes in release 0.40000. COPYRIGHT AND LICENSE
Copyright 2005, Carl Franks. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself (perlgpl, perlartistic). perl v5.18.2 2013-08-21 Perl6::Junction(3)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy