13,420
edits
Changes
no edit summary
{|width="40%" align="right" cellpadding="10"
|- valign="top"
|{{Admon/tip|Bash Shell Scripting Tips:|<br>'''<u>Arrays</u>'''<br><br><ul><li>Incredibly useful tool that works like a "storage container" of variables. '''Arrays have names like variables, but are numbered for quick storage and accessof related elements'''. Indices are I.D. numbers for array access. The first index starts at <u>'''zero '''</u> instead of '''1'''.<br><br></li><li>Instead of using index numbers, you can use I.D. names - : this is referred to as an '''Associative Array'''.<br><br></li><li>Examples:<br><br>''for((x=0; x<5; x++))''<br>''do''<br>'' read -p "Enter item #$((x+1)): " item[xx]''<br>''done''<br>''for((y=0; y<5; y++))''<br>''do''<br> ''echo ${item[y]}''<br>''done''<br><br>''set a b c''<br>''for x''<br>''do''<br> ''read -p "Enter item $x: " item["$x"]''<br> ''echo item[$x] is: ${item["$x"]}''<br>''done''<br><br>
</li></ul>}}
|}