Contents
- .
- ./env_var.sh
- ./for_params.sh
- ./hello.sh
- ./index.html
- ./myscript.sh
- ./variable.sh
. 1/7
[top][prev][next]
./env_var.sh 2/7
[top][prev][next]
#!/bin/bash
# Demonstrate use of environment variables
# by Sara Sprenkle
echo I am $USER
echo "I live at $HOME"
./for_params.sh 3/7
[top][prev][next]
#!/bin/bash
# Run an example where some of the command-line arguments are in quotes
# to see the variations
# by Sara Sprenkle
echo "The parameters: $*"
echo "The parameters: $@"
echo "The # of parameters: $#"
echo
echo 'Over $*'
for param in "$*"
do
echo $param
done
echo
echo '$@ Not in quotes'
for param in $@
do
echo $param
done
echo
echo '$@ In quotes'
for param in "$@"
do
echo $param
done
./hello.sh 4/7
[top][prev][next]
#!/bin/sh
# By Sara Sprenkle
echo "Hello, World!"
./index.html 5/7
[top][prev][next]
<html>
<head><title>Examples for /home/faculty/sprenkle/public_html/cs330/examples/bash_scripts</title>
<link rel="stylesheet" type="text/css" href="http://www.cs.wlu.edu/~sprenkle/cs330/css/themes/spacelab.min.css" />
<link rel="stylesheet" type="text/css" href="http://www.cs.wlu.edu/~sprenkle/cs330/css/course.css" />
<link rel="stylesheet" type="text/css" href="http://www.cs.wlu.edu/~sprenkle/cs330/css/syntax.css" />
<link rel="stylesheet" type="text/css" href="http://www.cs.wlu.edu/~sprenkle/cs330/css/style.css" />
</head>
<body>
<h1>Examples for /home/faculty/sprenkle/public_html/cs330/examples/bash_scripts</h1>
<ul>
<li><a href=".//code.html">All IN ONE FILE (pretty syntax)</a>
<li><a href=".//countlines">countlines</a></li>
<li><a href=".//countlines_params">countlines_params</a></li>
<li><a href=".//env_var.sh">env_var.sh</a></li>
<li><a href=".//for_params.sh">for_params.sh</a></li>
<li><a href=".//hello.sh">hello.sh</a></li>
<li><a href=".//myscript.sh">myscript.sh</a></li>
<li><a href=".//variable.sh">variable.sh</a></li>
</ul>
</body>
./myscript.sh 6/7
[top][prev][next]
#!/bin/bash
# silly example with for loops, conditionals, and command-line arguments
# Sara Sprenkle
# What happens when you enter a number that starts with 1 but is
# greater than 4?
# For example:
# bash myscript.sh 1 4 10 50 123
for x in $@
do
echo "$x"
if [[ $x < 4 ]]; then
echo "good!"
else
echo "yea!"
fi
done
./variable.sh 7/7
[top][prev][next]
#!/bin/bash
# by Sara Sprenkle
# Demonstrate different ways to use variables in echo statements
MESSAGE="Hello World!"
echo $MESSAGE
echo '$MESSAGE'
echo "$MESSAGE"
Generated by GNU Enscript 1.6.6.