Instructions:Omitted
Getting Ready:Omitted
[Enter]
refers to the "Enter" key.
[Tab]
refers to the "Tab" key.
[Down Arrow]
, [Up Arrow]
, etc... refer to the
down arrow key, up arrow key, etc...
[Ctrl]
refers to the "control" key and [Ctrl]+k
means that you should press the "control" key and the "k" key at the
same time.
The phrase "Enter the command xyz" means that you should type xyz
in the terminal/command-shell window and then press [Enter]
.
pwd
home
.)
mkdir cs
cd cs
pwd
mkdir labs
cd labs
pwd
command. (Note: You can change the BASH prompt by changing the value of the
shell variable named PS1
. For example, the command
export PS1="[\w]$ "
will change the prompt to the current working
directory in square barckets, followed by a dollar sign.)
javac WhatAnEgo.java
to compile
the source code.
WhatAnEgo.class
java WhatAnEgo
to execute the
byte code.
String
"Prof. ", the following error
was generated:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at WhatAnEgo.main(WhatAnEgo.java:15)
WhatAnEgo
uses args[0]
and we did not
supply the program with any command-line arguments.
java WhatAnEgo Bernstein
to execute the
byte code with a single command-line parameter.
Prof. Bernstein is the best!
Yes!
#!/bin/bash java WhatAnEgo Biggle java WhatAnEgo Broflovski java WhatAnEgo Cartman java WhatAnEgo McCormick
and not that each of this lines is a valid BASH command.
southpark.sh
in the directory
that contains WhatAnEgo.class
chmod +x southpark.sh
to make this file executable.
./southpark.sh
WhatAnEgo
was executed four times.
Prof. Biggle is the best!
Prof. Broflovski is the best!
Prof. Cartman is the best!
Prof. McCormick is the best!
nkdir skills_bash
(Note: This is
nkdir
not mkdir
!)
[Up Arrow]
key (or [Ctrl]+p
).
[Ctrl]+a
[Ctrl]+e
[Ctrl]+a
to go back to the first character.
[Ctrl]+d
[Enter]
cd ~
pwd
home
directory.
skills_bash
directory.
Save yourself some work by entering the command cd -
(which takes you back to the previous directory).
cd ..
pwd
skills_bash
directory.
Save yourself some work by typing cd sk[Tab]
(which tries to "complete" the directory name that starts with s).
[Enter]
to change to the skills_bash
directory.
pdw
but do not press [Enter]
. (Note:
This is pdw not pwd.)
[Ctrl]+t
to "twiddle" the last two characters.
[Enter]
.
mkdir temporary garbage
but do not press
enter.
[Ctrl]+w
[Enter]
.
pwd
(to see the name of the
current working directory).
ls
(to list all of the files
in this current working directory).
temporary
directory using
the rmdir
command. You could use the [Up Arrow]
a couple of times to re-type the mkdir
command. However,
save yourself some work by typing [Ctrl]+r
but
do not press [Enter]
.
[Ctrl]+a
to go to the first letter of the command.
[Ctrl]+d
twice to delete the m and k.
rm
to insert the letters r and m.
[Enter]
.
cd
(or cd ~
)
to move to your home
directory.
ls
ls -l
ls > filenames-short.txt
(which
will redirect the output of the ls
command to a file named
filenames-short.txt
)
ls -l > filenames-long.txt
(which
will redirect the output of the ls -l
command to a file named
filenames-long.txt
)
ls -R > filenames-all.txt
(where
the -R
option instructs the ls
command to
look in all subdirectories)
ls filenames*
(where the * is called the
wildcard character).
filenames-long.txt
and
filenames-all.txt
to the directory for this lab.
Save yourself some work by entering the command
mv filenames-{long,all}.txt cs/labs/skills_bash
[Tab]
key to
avoid having to type the directory names?
[Tab]
twice.
ls filenames*
rm filenames-short.txt
skills_bash
directory.
cd cs[Tab][Tab]
or cd -
ls
command by
entering the command
man ls
. (Note: You can get help on how to use "manual pages"
by pressing h
. [Ctrl]+n
and
[Ctrl]+p
work as expected, q
will quit/exit,
/
and ?
can be used to search forward and
backward.)
clear
command do? (Hint: Use the "manual
pages".)
cat
command do?
grep
command do?
less
command do?
sort
command do?
apropos
command do?
filenames-all.txt
file by entering the command
cat filenames-all.txt
. (Note: Make sure you are in the
correct directory.)
.txt
files in the current working directory by entering the command
grep Feb *.txt
less
command
to search for the first occurrence of the string
"Feb" in filenames-all.txt
.
cd
in the command shell window.
cd
command with the name of the
thumb drive.
cmd
) and how it differs from BASH
at the course help pages.
MSYS
. Follow the instructions in the section on
the "Graphical User Interface Installer".
(You might as well install some other
programming languages while you are at it, like, Ada, C++, Fortran, abd
Objective-C. You probably won't use them now but you may use them
later.)
Copyright 2013