Unable to understand if condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to understand if condition
# 1  
Old 07-08-2013
Unable to understand if condition

Hi geeks,
I am trying to understand below if statement. can someone please explain me meaning of if condition.

Code:
    if [[ ${DEBUG} == 1 ]]
    then
        echo -e "1"
    fi

Thanks
Moderator's Comments:
Mod Comment Please use CODE tags.

Last edited by Don Cragun; 07-08-2013 at 05:13 AM.. Reason: Add code tags.
# 2  
Old 07-08-2013
If the value of DEBUG variable is 1 then print 1
# 3  
Old 07-08-2013
Thanks for the reply, that i know but it has no value defined.
# 4  
Old 07-08-2013
Quote:
Originally Posted by jagnikam
Thanks for the reply, that i know but it has no value defined.
It is a debugging tool.

If you run the script with something like:
Code:
./yourscript argument...

the "then" clauses in "if"s like this will be ignored. But, if you run the script using something like:
Code:
DEBUG=1 ./yourscript argument...

the debugging notes provided by the "echo"s in those "if"s will be printed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

unable to understand the output of TRUSS command

Hi, I am trying to set ulimit for soft stack unlimited, but this is not taking effect, after tracing the ulimit -a unlimited command, the below output was generated, which i am unable to comprehend. Could any one help me with this? prcbap1-r10prod: truss -d ulimit -s unlimited Tue Dec 30... (2 Replies)
Discussion started by: NasirAbbasi
2 Replies

2. UNIX for Dummies Questions & Answers

Unable to understand RAID PARTITION

Hi i am studying about raid partion.i am not able to understand RAID level 5. below is excerpt taken from tutorial. RAID level 5 are they trying to say that the will be one extra disk which contain all the data. let says there are 4 disk. out of 4 , 3 disk are used for storing data and... (15 Replies)
Discussion started by: scriptor
15 Replies

3. UNIX for Dummies Questions & Answers

Unable to understand awk script.

Hi below is the samll awk script which i am not able to understand properly. here a bit confusion in 2nd line for me 1. why *\ is not used before . in second line as it was used in first line *\$*\. */ 2. why always \ is used in every first line 3. is there any specific meaning... (9 Replies)
Discussion started by: scriptor
9 Replies

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

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

7. UNIX for Dummies Questions & Answers

Unable to understand ps output.

I m executing ps command and sorting it according to memory usage. Please find the output of the command. # ps aux --sort pmem USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2060 624 ? Ss 01:54 0:00 init root 2 0.0... (1 Reply)
Discussion started by: pinga123
1 Replies

8. Solaris

Unable to understand disk layout and where are the free space

Hi I am unable to understand the disk layout of one of my disk attached to v240. This is newly installed system from jumpstart. I am unable to see the free space on backup slice 2 and there are 0 to 8 slices listed when I run format and print the disk info, also there is no reference of... (9 Replies)
Discussion started by: kumarmani
9 Replies

9. UNIX for Dummies Questions & Answers

unable to understand a awk code

i am not able to understand the following code for awk: $awk -F"|" '{ kount++} >END { for (desig in kount) > print desig,kount }' emp.list the input file i.e. emp.list is :: 3432| p.k.agrwal |g.m |sales 4566|g.l.sharma |director|production 3433|r shah | g.m | production... (1 Reply)
Discussion started by: streetfi8er
1 Replies

10. UNIX for Dummies Questions & Answers

Unable to understand associative nature of awk arrays

About associative nature of awk arrays i'm still confused, not able to understand yet how array element can be accessed based on a string, I got one example at gawk manual to illustrate associative nature of awk arrays, it goes here: Codeawk ' # Print list of word frequencies { for (i = 1;... (3 Replies)
Discussion started by: nervous
3 Replies
Login or Register to Ask a Question