Sponsored Content
Top Forums Shell Programming and Scripting Question on using "[[ ]]" in lieu of IF Construct Post 302285730 by cfajohnson on Monday 9th of February 2009 02:33:27 PM
Old 02-09-2009
Quote:
Originally Posted by otheus
There is no standard way, however, of doing negation in the UNIX shell using the && || constructs. One can, however, do something like this:
Code:
not() { 
  "$@"
  if [ $? = 0 ]; then return 1; else return 0; fi
}

# not true || echo false
false
# not false && echo true
true


What's wrong with the negation operator?

Code:
if ! some_command
then
  echo command failed
fi

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

3. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

4. Shell Programming and Scripting

Why stderr file descriptor redirection makes ksh's "select" construct hang.

I am trying to use one global declaration --> "exec 2>$ERR" to capture all stderr outputs that may occur anywhere in my script. Then close it at the end of the script using --> "exec 2<&-" I am using KSH on Solaris 8. KSH Version M-11/16/88i If I comment two "exec .." statements in the... (11 Replies)
Discussion started by: kchinnam
11 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

(CSH basic construct) "@" query

While going through a script, i came across few syntax which I am not aware of what they exactly means. @ cnt = 1 @ num_all = `echo $var` What is the significance of "@" here. What is it called? (3 Replies)
Discussion started by: animesharma
3 Replies

7. Solaris

"Estream construct failed" Error on Solaris i86pc

Hi Guys, From past some days, I am getting an error in /var/adm/messages which is as shown below. XXXXX02:/# cat /var/adm/messages |tail Sep 16 15:28:14 XXXX02 EV_AGENT: Agent Main --Estream construct failed. Err: EMULSocket::recv() Sep 16 15:31:49 XXXX02 EV_AGENT: Agent main --... (2 Replies)
Discussion started by: vivek.goel.piet
2 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
Data::FormValidator::ConstraintsFactory(3pm)		User Contributed Perl Documentation	      Data::FormValidator::ConstraintsFactory(3pm)

NAME
Data::FormValidator::ConstraintsFactory - Module to create constraints for HTML::FormValidator. DESCRIPTION
This module contains functions to help generate complex constraints. If you are writing new code, take a look at Data::FormValidator::Constraints::MethodsFactory instead. It's a modern alternative to what's here, offering improved names and syntax. SYNOPSIS
use Data::FormValidator::ConstraintsFactory qw( :set :bool ); constraints => { param1 => make_or_constraint( make_num_set_constraint( -1, ( 1 .. 10 ) ), make_set_constraint( 1, ( 20 .. 30 ) ), ), province => make_word_set_constraint( 1, "AB QC ON TN NU" ), bid => make_range_constraint( 1, 1, 10 ), } BOOLEAN CONSTRAINTS
Those constraints are available by using the ":bool" tag. make_not_constraint( $c1 ) This will create a constraint that will return the negation of the result of constraint $c1. make_or_constraint( @constraints ) This will create a constraint that will return the result of the first constraint that return an non false result. make_and_constraint( @constraints ) This will create a constraint that will return the result of the first constraint that return an non false result only if all constraints returns a non-false results. SET CONSTRAINTS
Those constraints are available by using the ":set" tag. make_set_constraint( $res, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. The "eq" operator is used for comparison. make_num_set_constraint( $res, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. The "==" operator is used for comparison. make_word_set_constraint( $res, $set ) This will create a constraint that will return $res if the value is a word in $set, or the negation of $res otherwise. make_cmp_set_constraint( $res, $cmp, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. $cmp is a function which takes two argument and should return true or false depending if the two elements are equal. NUMERICAL LOGICAL CONSTRAINTS
Those constraints are available by using the ":num" tag. make_clamp_constraint( $res, $low, $high ) This will create a constraint that will return $res if the value is between $low and $high bounds included or its negation otherwise. make_lt_constraint( $res, $bound ) This will create a constraint that will return $res if the value is lower than $bound, or the negation of $res otherwise. make_le_constraint( $res, $bound ) This will create a constraint that will return $res if the value is lower or equal than $bound, or the negation of $res otherwise. make_gt_constraint( $res, $bound ) This will create a constraint that will return $res if the value is greater than $bound, or the negation of $res otherwise. make_ge_constraint( $res, $bound ) This will create a constraint that will return $res if the value is greater or equal than $bound, or the negation of $res otherwise. OTHER CONSTRAINTS
make_length_constraint($max_length) This will create a constraint that will return true if the value has a length of less than or equal to $max_length SEE ALSO
Data::FormValidator(3) AUTHOR
Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> Maintainer: Mark Stosberg <mark@summersault.com> COPYRIGHT
Copyright (c) 2000 iNsu Innovations Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms as perl itself. perl v5.14.2 2011-11-25 Data::FormValidator::ConstraintsFactory(3pm)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy