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;
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;
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
LAST 5 TIPS
- SOLARIS 9/10: IP FROM IFCONFIG
- HIGHEST MEMORY PROCESS
- CHECKING BRACKETS USING VIM
- ANOTHER WAY TO KILL A USER
- CHANGE OWNERSHIP BY USER
I want to
and get a UGU Tip everyday.
I want to
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-2011 Unix Guru Universe