Open main menu

CDOT Wiki β

Changes

OPS235 Lab 6 - CentOS7 - SSD

66 bytes added, 10:18, 14 June 2016
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 access of 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&#61;0; x&lt;5; x++)) # Example of a regular array''<br>''do''<br>'' &nbsp; read -p "Enter item #$((x+1)): " item[xx]''<br>''done''<br>''for((y&#61;0; y&lt;5; y++))''<br>''do''<br> &nbsp; ''echo ${item[y]}''<br>''done''<br><br>''set a b c''# Example of an "Associative Array"<br>''for x''<br>''do''<br> &nbsp; ''read -p "Enter item $x: " item["$x"]''<br> &nbsp; ''echo item[$x] is: ${item["$x"]}''<br>''done''<br><br>
</li></ul>}}
|}
13,420
edits