| 
       
       
             | 
              | 
            
            
            
              
             
             
               
               
               
                  | 
                 
UGU: Unix Guru Universe - Unix Tip #4277- November 26, 2012
 -  Home : Help
 : Today's Tip
 Unix Tip #4277- November 26, 2012
 
VARIABLE USAGE i or ii  
  
In cases like the following, you will notice a  
variable, $i, put into use.  Variables such  
as "i, j, k" are commonly used not only in  
simple shell scripts, but all types of code.  
  
for i in 1, 2, 3, 4, 5, 6;  
do;  
echo $i;  
sleep $i;  
done  
  
A better practice for these "$i, $j, $k"  
temporary, short term use variables, is to named  
them "$ii, $jj, $kk."  Why, you ask?  Go pick  
any piece of code, or script.  Pretend it's  
buggy, and you need to find the culprit, which  
you suspect is in a variable, "i."  Search  
for "i" within the code.  How many results are  
there?  Now, take a piece of code using "ii,  
jj, kk" variable names.  Go search for "ii" and  
you'll find that only your variables are found!  
Makes searching code sooo much easier.  
  
for ii in 1 2 3 4 5;  
do;  
echo $ii;  
sleep $ii;  
done  
  
  
 NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted
by various unix admins around the globe. UGU suggest you read and
test each tip in a non-volitile environment before placing into
production.
  
LAST 5 TIPS
 4276
 - SOLARIS 9/10: IP FROM IFCONFIG 
 4275
 - HIGHEST MEMORY PROCESS
 4274
 - CHECKING BRACKETS USING VIM
 4273
 - ANOTHER WAY TO KILL A USER
 4272
 - CHANGE OWNERSHIP BY USER
 
I want to 
 SUBSCRIBE
 and get a UGU Tip everyday. 
I want to 
 UNSUBSCRIBE
 and NOT get a UGU Tip everyday.
 
If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
                 
                  | 
                
                
                | 
                
               
                 |   | 
                
               
                   Copyright 1994-2024 Unix Guru Universe    | 
                
                
                | 
              
              
              | 
              | 
            
            
           
             |