Open main menu

CDOT Wiki β

Changes

OPS235 Lab 6 - CentOS7 - SSD

147 bytes added, 21:58, 13 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. Indices are I.D. numbers for array access. The first index starts at zero 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>''#!/bin/bash''<br>''for((x&#61;0; x&lt;5; x++))''<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>#!/bin/bash<br>set a b c<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