Difference between revisions of "BASH"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) |
Rafahsolis (talk | contribs) (→While) |
||
| Line 24: | Line 24: | ||
=== Loops === | === Loops === | ||
==== While ==== | ==== While ==== | ||
| + | <source lang="bash"> | ||
| + | #!/bin/bash | ||
| + | COUNTER=0 | ||
| + | while [ $COUNTER -lt 10 ]; do | ||
| + | echo The counter is $COUNTER | ||
| + | let COUNTER=COUNTER+1 | ||
| + | done | ||
| + | </source> | ||
| + | |||
==== For ==== | ==== For ==== | ||
=== Conditional === | === Conditional === | ||
Revision as of 00:52, 27 March 2015
BASH Script
Hello World
#!/bin/bash
STR="Hello World"
echo $STR
Variables
Local Variables
#!/bin/bash
HELLO=Hello
function hello {
local HELLO=World
echo $HELLO
}
echo $HELLO
hello
echo $HELLO
Strings
Loops
While
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done