Sponsored Content
Full Discussion: How does ||: evaluate?
Top Forums UNIX for Dummies Questions & Answers How does ||: evaluate? Post 302753899 by glev2005 on Wednesday 9th of January 2013 02:52:51 PM
Old 01-09-2013
How does ||: evaluate?

In BASH, how does ||: get interpreted. I know || is logical or. And I believe : evaluates to true. Can someone give a thorough explanation for this usage?

Example
Code:
for i in $IGGY
	do
	    [ "$db" == "$i" ] && skipdb=1 || :

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get variable to re-evaluate itself?

Probably a simple one. Basically I am retrieving a number from a file - setting a variable against it and then incrementing this by 1 and using this as an entry number in a log file for messages. I need the variable to re-evalute itself each time I call it so I get the latest number in the file -... (1 Reply)
Discussion started by: frustrated1
1 Replies

2. Shell Programming and Scripting

How to evaluate the value read from a file?

Hi, Could someone please help me with how to do the following? Say I have a flat file test.lst and the content of the file is: Report Date - `date '+%m%d%Y'` I'm trying the following while read myLine do echo ${myLine} done<test.lst This prints Report Date - `date... (1 Reply)
Discussion started by: arunsoman80
1 Replies

3. Shell Programming and Scripting

Evaluate the value of a variable?

I have variables: FOO="Text" BAR="FOO" I'd like to be able to evaluate the variable named as the value of $BAR. echo $FOO Text echo $BAR FOO This is what I'd like to do: echo ${$BAR} (this won't work) Text (3 Replies)
Discussion started by: Ilja
3 Replies

4. Programming

How to evaluate which coding approach is best?

Let's say for example that we have two different ways was can code the exact same program to achieve the same result. What is the best way to determine which of the two methods is the best solution? Is it as simple as basing it on how long the program takes to run or is there a more... (4 Replies)
Discussion started by: jmvbxx
4 Replies

5. Shell Programming and Scripting

cron does not evaluate the quotes

Hi all, I have a script that runs perfectly from cmd, but in the cron it gives a strange ':::::::::::::::' output instead of evaluating the part inside the quotes. this is the script: bash-3.00# more test #!/bin/ksh #-----swap--- TEMP_FILE=/HealthCheck/test/file.txt swap -s | tee... (1 Reply)
Discussion started by: kerrygold
1 Replies

6. Shell Programming and Scripting

How to evaluate the value of a variable ?

How to evaluate the value of a variable ? For example: a=var $a=value !!!error happens!!! I want to evaluate var=value, how to realize it? Thanks! ---------- Post updated at 03:37 AM ---------- Previous update was at 02:22 AM ---------- I am using linux bash. a=var $a=value... (4 Replies)
Discussion started by: 915086731
4 Replies

7. Shell Programming and Scripting

Evaluate Variable At Runtime

Hi, I am trying to set a variable that has time the format desired. And my intention is to echo variable (instead of actual date command) everytime I like to echo date. Please take a look at below code. $NOW='' echo $NOW After 5 minutes $echo $NOW Issue here is , I am not... (2 Replies)
Discussion started by: vinay4889
2 Replies

8. Shell Programming and Scripting

Evaluate Expression within awk

I want to create a conditional expression string and pass in an awk script. My script is as below... comm="\$3 == "hello"" awk -F "^T" -v command="${comm}" ' { if ( command ) { print "hye" } }' testBut the statement "if ( command )" always evaluates to true which is not... (5 Replies)
Discussion started by: Saikat123
5 Replies

9. UNIX for Advanced & Expert Users

How to evaluate expression under awk?

I have to display only those subscribers which are in "unconnected state" and the date is 90 days older than today's date. Below command is used for this purpose: cat vfsubscriber_20170817.csv | sed -e 's/^"//' -e '1d' | \ nawk -F '",' '{if ( (substr($11,2,4) == 2017) && ( substr($11,2,8)... (1 Reply)
Discussion started by: dia
1 Replies
EXPR(1) 						    BSD General Commands Manual 						   EXPR(1)

NAME
expr -- evaluate expression SYNOPSIS
expr expression DESCRIPTION
The expr utility evaluates expression and writes the result on standard output. All operators and operands must be passed as separate arguments. Several of the operators have special meaning to command interpreters and must therefore be quoted appropriately. All integer operands are interpreted in base 10 and must consist of only an optional leading minus sign followed by one or more digits. Arithmetic operations are performed using signed integer math with a range according to the C intmax_t data type (the largest signed integral type available). All conversions and operations are checked for overflow. Overflow results in program termination with an error message on stdout and with an error status. Operators are listed below in order of increasing precedence; all are left-associative. Operators with equal precedence are grouped within symbols '{' and '}'. expr1 | expr2 Return the evaluation of expr1 if it is neither an empty string nor zero; otherwise, returns the evaluation of expr2 if it is not an empty string; otherwise, returns zero. expr1 & expr2 Return the evaluation of expr1 if neither expression evaluates to an empty string or zero; otherwise, returns zero. expr1 {=, >, >=, <, <=, !=} expr2 Return the results of integer comparison if both arguments are integers; otherwise, returns the results of string comparison using the locale-specific collation sequence. The result of each comparison is 1 if the specified relation is true, or 0 if the relation is false. expr1 {+, -} expr2 Return the results of addition or subtraction of integer-valued arguments. expr1 {*, /, %} expr2 Return the results of multiplication, integer division, or remainder of integer-valued arguments. expr1 : expr2 The ``:'' operator matches expr1 against expr2, which must be a basic regular expression. The regular expression is anchored to the beginning of the string with an implicit ``^''. If the match succeeds and the pattern contains at least one regular expression subexpression ``(...)'', the string corresponding to ``1'' is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern contains a regular expression subexpression the null string is returned; otherwise 0. Parentheses are used for grouping in the usual manner. The expr utility makes no lexical distinction between arguments which may be operators and arguments which may be operands. An operand which is lexically identical to an operator will be considered a syntax error. See the examples below for a work-around. The syntax of the expr command in general is historic and inconvenient. New applications are advised to use shell arithmetic rather than expr. EXIT STATUS
The expr utility exits with one of the following values: 0 the expression is neither an empty string nor 0. 1 the expression is an empty string or 0. 2 the expression is invalid. EXAMPLES
o The following example (in sh(1) syntax) adds one to the variable a: a=$(expr $a + 1) o This will fail if the value of a is a negative number. To protect negative values of a from being interpreted as options to the expr command, one might rearrange the expression: a=$(expr 1 + $a) o More generally, parenthesize possibly-negative values: a=$(expr ( $a ) + 1) o With shell arithmetic, no escaping is required: a=$((a + 1)) o This example prints the filename portion of a pathname stored in variable a. Since a might represent the path /, it is necessary to pre- vent it from being interpreted as the division operator. The // characters resolve this ambiguity. expr "//$a" : '.*/(.*)' o With modern sh(1) syntax, "${a##*/}" expands to the same value. The following examples output the number of characters in variable a. Again, if a might begin with a hyphen, it is necessary to prevent it from being interpreted as an option to expr, and a might be interpreted as an operator. o To deal with all of this, a complicated command is required: expr ( "X$a" : ".*" ) - 1 o With modern sh(1) syntax, this can be done much more easily: ${#a} expands to the required number. SEE ALSO
sh(1), test(1) STANDARDS
The expr utility conforms to IEEE Std 1003.1-2008 (``POSIX.1''). The extended arithmetic range and overflow checks do not conflict with POSIX's requirement that arithmetic be done using signed longs, since they only make a difference to the result in cases where using signed longs would give undefined behavior. According to the POSIX standard, the use of string arguments length, substr, index, or match produces undefined results. In this version of expr, these arguments are treated just as their respective string values. BSD
September 9, 2010 BSD
All times are GMT -4. The time now is 01:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy