Query in if condition


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Query in if condition
# 1  
Old 04-13-2014
Query in if condition

----
Code:
srcfile=/xxx/yyy/abc.txt
Mode=1
if [ -s $srcfile -o "$Mode" -eq "0" ]; then
        
    echo "inside if"
else
    echo "not inside if"
fi

----

The size of the file /xxx/yyy/abc.txt is 1 mb
If i exec the above if condition, what is the output that i will get?

what does "-o " means in the if condition

The version is unix that i am using is AIX 6.1

Thanks
Krishnakanth Manivannan

Last edited by bartus11; 04-13-2014 at 06:47 PM.. Reason: Please use [code][/code] tags.
# 2  
Old 04-13-2014
Quote:
Originally Posted by kmanivan82
----
Code:
srcfile=/xxx/yyy/abc.txt
Mode=1
if [ -s $srcfile -o "$Mode" -eq "0" ]; then
        
    echo "inside if"
else
    echo "not inside if"
fi

----

The size of the file /xxx/yyy/abc.txt is 1 mb
If i exec the above if condition, what is the output that i will get?
Code:
inside if

Quote:
Originally Posted by kmanivan82
what does "-o " means in the if condition
or
Quote:
Originally Posted by kmanivan82
The version is unix that i am using is AIX 6.1

Thanks
Krishnakanth Manivannan
Rather than posting to this forum to answer questions like this wouldn't it be a lot simpler to just execute the if statement to see what output it produces and run the command:
Code:
man [
  or
man test

and look for the description of the -o binary operator?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with if condition

o/p of my command is given below My requirement is if Pnumber is 0 then stabilization.Build.2013 else stabilization.PBuild.2013.3 (11 Replies)
Discussion started by: nikhil jain
11 Replies

2. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

3. Shell Programming and Scripting

if condition

if chr1:109457160 1 109457160 99.1735537190083 + chr1:109457233 1 109457233 99.1735537190083 - chr1:109457614 1 109457614 99.1735537190083 + chr1:109457618 1 109457618 100 + chr1:109457943 1 109457943 100 - chr1:109458224 1 109458224 99.1735537190083 - file1.txt If 6th column in... (3 Replies)
Discussion started by: johnkim0806
3 Replies

4. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

5. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Programming

sql query to match condition from other table (time sensitive)

I know little SQL and could really use a hand here. I need to get the fields last_name, first_name and email from the table users and only if the entery with the same pkey in the table addresses, in the city column is Seattle. So if the city in the addresses table is Seattle, go to the table... (2 Replies)
Discussion started by: computethis
2 Replies

7. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

8. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

9. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

10. Shell Programming and Scripting

if condition ...

i have following if condition if above statement is case sensitive.....what is syntax if i have to make above comparision case insensetive (4 Replies)
Discussion started by: mahabunta
4 Replies
Login or Register to Ask a Question