Sponsored Content
Top Forums Shell Programming and Scripting nested logical expression in bash shell Post 302591896 by ahamed101 on Saturday 21st of January 2012 11:36:25 AM
Old 01-21-2012
Code:
if [[ 1 -eq 1 && ( 2 -eq 2 || 2 -eq 3 ) ]]
then
  echo "true"
else
  echo "false"
fi

--ahamed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use regular expression in Bash Shell Scripting

Hi, Actually i have written one test.sh (shell program) in bash. Here i have a variables $a which stored the value package1. Now I want to write a regular expression inside the if command that "if $a variable contains letter p in the begining of the value package1 then it is coming true.... (5 Replies)
Discussion started by: sunitachoudhury
5 Replies

2. Shell Programming and Scripting

Can you use logical operators in a case statement (bash)?

I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

3. Shell Programming and Scripting

Need help in Regular expression in bash shell

hi, I have written a script to search MAC address in a given directory. MAC address would be in format XX.XX.XX.XX. The digits contain hexadecimal numbers. For this i have used grep as follows. grep -rn '^\{1,2\}\.\{1,2\}\.\{1,2\}\.\{1,2\}\$' * This is not working as required.... (17 Replies)
Discussion started by: flamingo_l
17 Replies

4. Shell Programming and Scripting

Nested if question BASH

Just started learning bash ,and I am confused with sintaksis line 16: syntax error near unexpected token `else' thanks #!/bin/bash echo -n "Enter: " read num if(($(echo ${#num}) == 0 )) then echo No arguments passed.Try again elif rem=$(echo $num | tr -d ) ... (7 Replies)
Discussion started by: lio123
7 Replies

5. Shell Programming and Scripting

Nested for loop in bash

Hi, How to use values in one for loop to other for loop. say "$sf_rel" variable has values "2011/W2 2011/G2" I want to use these values in inner for loop to process properly. $branch variable has G2 and 6 What is happening is outer for loop $i has 2011/W2 it is entering into inner... (3 Replies)
Discussion started by: Anjan1
3 Replies

6. Shell Programming and Scripting

Using Logical Expression in an AWK statement

I'm would to create a script that would give me the results below. Please note the spaces in the log file are actually commas(",".) Log file Data 0:00 21:15 899 43 31 12 25.39 0:00 21:20 736 34 19 15 35.39 0:00 21:20 776 41 28 13 ... (3 Replies)
Discussion started by: ravzter
3 Replies

7. Shell Programming and Scripting

Logical expression in POSIX compliant Korn Shell

Hi, i want to check if a variable var1 is not a or b or c pseudo code: If NOT (var1 = a or var1 = b or var1 = c) then ... fi I want to use POSIX complaint Korn shell, and for string comparison For the following code, logical.sh #!/usr/bin/ksh var="j" echo "Var : $var" if ! { || ||... (12 Replies)
Discussion started by: ysrini
12 Replies

8. UNIX for Dummies Questions & Answers

Im new to bash scriping and i found this expression on a bash script what does this mean.

# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi espeacailly the top regex part? ---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
Discussion started by: kevin298
1 Replies

9. Shell Programming and Scripting

Help with nested $s and quotations in bash / awk

Folks - newbie bash coder here and I'd like to get your help to make the code below work. As you can see, I was trying to count the total number of lines with the 3rd value >= 15 in a file and wanted to make the threshold "15" configurable, but apparently the $THRESHOLD value was not populated... (3 Replies)
Discussion started by: bashzipper
3 Replies

10. UNIX for Dummies Questions & Answers

Nested loop -bash

I am using the following nested loop for i in {1..3} do for y in {1..3} do if ; then echo P0${i}R${y}.fas mv P0${i}R${y}.fas P${i}R${y}.fas read -t 5 fi done done I was wondering if I can use a character such as * or ? instead of my second variable y. I tried R in... (3 Replies)
Discussion started by: Xterra
3 Replies
IS_STRING(3)								 1							      IS_STRING(3)

is_string - Find whether the type of a variable is string

SYNOPSIS
bool is_string (mixed $var) DESCRIPTION
Finds whether the type given variable is string. PARAMETERS
o $var - The variable being evaluated. RETURN VALUES
Returns TRUE if $var is of type string, FALSE otherwise. EXAMPLES
Example #1 is_string(3) example <?php $values = array(false, true, null, 'abc', '23', 23, '23.5', 23.5, '', ' ', '0', 0); foreach ($values as $value) { echo "is_string("; var_export($value); echo ") = "; echo var_dump(is_string($value)); } ?> The above example will output: is_string(false) = bool(false) is_string(true) = bool(false) is_string(NULL) = bool(false) is_string('abc') = bool(true) is_string('23') = bool(true) is_string(23) = bool(false) is_string('23.5') = bool(true) is_string(23.5) = bool(false) is_string('') = bool(true) is_string(' ') = bool(true) is_string('0') = bool(true) is_string(0) = bool(false) SEE ALSO
is_float(3), is_int(3), is_bool(3), is_object(3), is_array(3). PHP Documentation Group IS_STRING(3)
All times are GMT -4. The time now is 02:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy