if condition in shellscript


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting if condition in shellscript
# 1  
Old 12-20-2011
if condition in shellscript

Hi All,

I tried below code

getting error.

AD=0
ZERO=0

Code:
 
if [ $AD == $ZERO ] then
echo "AD is zero select another symbol"
fi

Code:
syntax error near unexpected token `fi'

plz help me to solve this error
# 2  
Old 12-20-2011
Numerical Comparator .. Go with -eq option instead of == And also ; is missing ..
Code:
if [ $AD -eq $ZERO ] ; then

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 12-20-2011
Wrong syntax.
Try this:
Code:
if [ $AD -eq $ZERO ]
then
    echo "blah blah"
fi

This User Gave Thanks to balajesuri For This Post:
# 4  
Old 12-20-2011
Code:
if [$AD  -eq $ZERO ] 
then
echo '$AD is zero select another symbol'
fi

This User Gave Thanks to h@foorsa.biz For This Post:
# 5  
Old 12-20-2011
Thanks to all !!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk in shellscript

Dear Members, I have the following situation I do not understand: I have a large json encoded file which I need to grep and afterwards want to extract specific information. I use this command to to that: cat /tmp/file | awk -F '"fields":' '{print $2}' | awk -F '"description":' '{print $4}'... (6 Replies)
Discussion started by: crumble
6 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

Help with shellscript

I am new in shell script i want to convert .txt file in the format axsjdijdjjdk to a x s j d i j d j j d k (5 Replies)
Discussion started by: sreejithalokkan
5 Replies

4. Shell Programming and Scripting

Shellscript Reengineering

Dear Community, I've an urgent issue due to a migration of an application from HP-Unix to Linux. We have a mass of scripts which are running at a dedicated server on hpunix. Now we do not know, which further scripts exists on this machine. the idea is, that we crawl through the scripts we... (1 Reply)
Discussion started by: Alibapir
1 Replies

5. UNIX for Dummies Questions & Answers

How can I do aliasing in shellscript?

#Example.sh alias rmv 'sh Example2.sh' when i execute exapme.sh alias name not working. how i solve this problem?? (9 Replies)
Discussion started by: arun508.gatike
9 Replies

6. 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

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

Need help with shellscript

Hello. I am a novince at writing shell scripts but here is the question. I have to write a shell script that does the following: Once executed via crontab, the script should do the following: a. get date/time stamp in for format 10-MAR-05 and b. execute shell script my_script.sh (which... (2 Replies)
Discussion started by: jigarlakhani
2 Replies

9. Shell Programming and Scripting

Another shellscript question

Folks; on a unix server I have a mapping file which holds a list mountpoints of all databases and their mountpoints. tab delimited or colon deliminted..I needed to copy the datafiles from the pristine mountpoints to test's mountpoints in this case. I needed to do this by passing sid name using... (18 Replies)
Discussion started by: jigarlakhani
18 Replies
Login or Register to Ask a Question