cd ~/it244/ex
mkdir ex18
cd ex18
echo
echo Go \[Enter] Red \[Enter] Sox [Enter]The greater than symbol, > , that you see after all but the last time you hit Enter is a secondary prompt.
echo The University \[Enter] of Massachusetts \[Enter] at Boston [Enter]
echo Hello \[Space][Enter]The
echo
command does not wait for further input, it prints
its argument and you don't get a secondary prompt.
PS1='===> 'Note the single quotes.
PS2='>> '
echo Go \[Enter] Red \[Enter] Sox [Enter]You should see your new secondary prompt with each new line.
echo
commands on the same command lineecho foo; echo bar; echo bletchEach echo command generates its own line of output.
echo
commands on the same lineecho Unix; echo is not; echo for the faint of heart
echo; echo This is what is in my home directory:; ls -al ~
cp ~ghoffman/course_files/it244_files/hi_bye.sh .
cat hi_bye.sh
jobs
command./hi_bye.sh & ./hi_bye.sh & jobsThe ampersand causes each of the two invocations of hi_bye.sh to run in the background.
jobs
is able to report on the two invocations of hi_bye.sh running
in the background, because it is running in the foreground.
echo $PATH
echo $HOME
echo $SHELL
echo $PS2
env
greeting=Hello
echo $greeting
greeting='Hello there'
echo $greeting
cp ~ghoffman/course_files/it244_files/print_foo.sh .
cat print_foo.shThis script simply prints the value of the variable foo to Standard Output.
foo=FOO
echo $foo
./print_foo.shThe script prints no value for foo, since foo was a local variable defined in your original shell.
export foo=BAR
echo $foo
./print_foo.shSince the
export
command makes foo a global variable,
print_foo.sh can now see this variable in the subshell in which
it is run.
cd ~ghoffman/course_files/it244_files/dir_tree
pwd
ls
dirs
to look at the directory stackdirsIt only lists the current directory.
pushd
pushd projTwo directories are now listed.
pwd
ls
pushd proj1Three directories are now listed.
pwd
popd
popdNow, only two directories are listed, because you poped the previous directory from the stack.
pwd
popd > /dev/null; pwdBy redirecting output to /dev/null, you have stopped
popd
from printing out the directory stack.
pwd
, you have displayed your current location
without having to wait for a prompt.
cd ~/it244/ex/ex18
nano ex18.sh
chmod 755 ex18.sh
bash ex18.sh > /dev/nullRunning ex18.sh this way will only print error messages.
~ghoffman/it244_test/ex18.shWhen the script asks if you are ready for more, hit Return or Enter.