UGU Unix Guru Universe
For Unix Admins, By Unix Admins
Follow ugucom on Twitter      Search  in 
Home
BEGINNERS & USERS

Events

Internet
 
 Linux
BEGINNERS & USERS
Software
Linux Vendors
Usenet NewsGroups
Books & Publications
 
 Shop
Cool Admin Gifts!
Gadgets
T-Shirts
Books
 
 Unix Guru Universe
About
Add Link
Feedback
 
 
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)
Email Address:

Yes, email me a Hot Unix Tip everday.

Enter Hot Unix Tip (optional):

Yes, I will support this tip

Captcha (not case sensitive):


Please enter the above letters:

 
Copyright 1994-2024 Unix Guru Universe