cd ~/it244/ex
mkdir ex17
cd ex17
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 line
echo foo; echo bar; echo bletch
Each echo command generates its own line of output.
echo commands on the same line
echo Unix; echo is not; echo for the faint of heart
echo; echo This is what is in my home directory:; ls -al ~
cp ~tsoro/course_files/it244_files/hi_bye.sh .
cat hi_bye.sh
jobs command
./hi_bye.sh & ./hi_bye.sh & jobs
The 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 ~tsoro/course_files/it244_files/print_foo.sh .
cat print_foo.sh
This script simply prints the value of the variable foo to Standard Output.
foo=FOO
echo $foo
./print_foo.sh
The script prints no value for foo,
since foo was a local variable defined
in your original shell.
export foo=BAR
echo $foo
./print_foo.sh
Since 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 ~tsoro/course_files/it244_files/dir_tree
pwd
ls
dirs to look at the directory stack
dirs
It only lists the current directory.
pushd
pushd proj
Two directories are now listed.
pwd
ls
pushd proj1
Three directories are now listed.
pwd
popd
popd
Now, only two directories are listed, because you poped the previous directory from the stack.
pwd
popd > /dev/null; pwd
By 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/ex17
nano ex17.sh
chmod 755 ex17.sh
bash ex17.sh > /dev/null
Running ex17.sh this way
will only print error messages.
~tsoro/it244_test/ex17.sh
When the script asks if you are ready for more, hit Return or Enter.