script
Commandpwd
- Show Your Current Directorycd
- Change Directoryls
- List the Contents of a Directorycat
- Print the Contents of a Filerm
- Delete a Filemkdir
- Create a Directoryrmdir
- Delete a Directorycp
- Copy Filesmv
- Move a File or DirectoryI have posted homework 2.
As usual, it will be due this coming Sunday at 11:59 PM.
The first graded quiz will be given on Tuesday next week.
The questions from the graded quiz are taken from the ungraded quizzes of the previous week.
Unless I tell you otherwise, you should expect a graded quiz each week.
The quiz will be available on Gradescope on Tuesday.
The quiz will be available from the Gradescope web site but only for the last 15 minutes of the class.
Once you start the quiz, you will have 15 minutes to finish it.
If you do not take the quiz when it is offered you cannot take it at another time because Gradescope does not permit this.
If you fail to take the quiz but have a valid excuse, send me an email.
In order to take the quiz on Gradescope, you need to sign in to my Gradescope section.
Sometime during the next few days I will enter all your UMB email addresses into Gradescope.
You will receive an email from Gradescope.
What happens next depends on whether you have already registered with Gradescope.
If you are new to Gradescope
If you are already registered with Gradescope
You will find more information about Gradescope here.
You will find links to the recordings of class meetings here.
Are there any questions before I begin?
putty
Blank Screen Problemputty
get a blank screen
~ghoffman/it244_test/ex04.sh
script
Commandscript
command creates a transcript of your Unix sessionscript
creates a text file named typescript
in your current directory
script
a second time will overwrite the previous typescript file script -a
-a
option, script
will add to the previous typescript filescript
session you must type "exit" -h
as the help option--help
man
or info
man
or info
with the name of the command
& : | * ? ' " [ ] ( ) $ < > { } # / \ ! ~
echo
command prints whatever comes after it$ echo Hello World! Hello World!
echo
with the special character ~
$ echo ~ /home/ghoffman
echo
if put a backslash in front of it
$ echo \~ ~
$ echo '~' ~ $ echo "~" ~
pwd
- Show Your Current Directorypwd
(print working directory) displays your current directory
pwd
pwd
every time you use cd
cd
- Change Directorycd
(change directory) changes your current directorycd
to move from one directory to another
cd DIRECTORY_NAME
cd
with an argument it moves you to that directorycd
without an argument it takes you to your
home directory
cd ..
cd ../..
ls
- List the Contents of a Directoryls
(list) is one of the most basic Unix commandsls
with or without an argumentls
a directory name, it lists what is inside that directory
$ ls it244_test 1 ex06.sh ex12.sh ex20.sh ex24.sh five_lines.txt 1.sh ex07.sh ex13.sh ex21.sh ex25.sh script_improvements.txt ex02.sh ex08.sh ex16.sh ex22.sh ex26.sh step_comment_check.sh ex03.sh ex09.sh ex17.sh ex22_sum.sh ex27.sh ex04.sh ex10.sh ex18.sh ex23.sh ex_list.sh ex05.sh ex11.sh ex19.sh ex23_sum.sh exnn.sh
ls
an argument it lists the current directory
$ pwd /home/ghoffman $ ls bin course_materials it116 it244 stdwrk tmp bugs demos it116_test it244_test submitted wrk code haoyu it117 mail testing xrchiv course_files html it117_test public_html tests_taken
ls
can help you know you are in the right directoryls
has many options-l
(el) option gives you a long listing
$ ls -l total 20 -rw-rw-r-- 1 ghoffman 103 Sep 11 14:34 basic.css -rw-r--r-- 1 ghoffman 3560 Aug 29 13:30 emacs_cheat_sheet.html -rw-r--r-- 1 ghoffman 701 Aug 29 13:30 index.html drwxr-xr-x 6 ghoffman 512 Sep 15 14:11 it_244 -rw-r--r-- 1 ghoffman 6831 Aug 29 13:30 tips.html -rw-r--r-- 1 ghoffman 6052 Aug 29 13:30 unix_cheat_sheet.html
-a
(for all) option also lists files whose names begin with . (dot)ls
will not show them unless you use -a
cat
- Print the Contents of a Filecat
(concatenate) prints a file
$ cat foo.txt foo bar blecth
-n
option cat
displays line numbers
$ cat -n numbered_lines.txt 1 Line 1 2 Line 2 3 Line 3 4 Line 4 5 Line 5
cat
on a long file, the output can
scroll off the screen
rm
- Delete a Filerm
(remove) deletes a file
rm FILENAME
rm *
rm
rm
with the -i
option it will ask you before deleting each file
rm -i * rm: remove regular file `foo.txt'? y [Enter]
rm *
rm
cannot remove a directory unless you use a special optionmkdir
- Create a Directorymkdir
(make directory) creates a directory
mkdir DIRECTORY_NAME
rmdir
- Delete a Directoryrmdir
(remove directory) deletes a directory
rmdir DIRECTORY_NAME
rmdir
will not work unless the directory is emptycp
- Copy Filescp
(copy) makes a copy of a file or a directory
cp FILENAME DIRECTORY_OR_NEW_FILENAME
cp
takes two arguments$ ls dir foo.txt $ ls dir $ cp foo.txt dir $ ls dir/ foo.txt
$ cp foo.txt bar.txt $ ls bar.txt dir foo.txt
-r
optionmv
- Move a File or Directorymv
(move) is a command that does two different things
mv FILENAME_OR_DIRECTORY_NAME NEW_DIRECTORY
mv FILENAME_OR_DIRECTORY_NAME NEW_FILENAME_OR_NEW_DIRECTORY_NAME
mv
takes two arguments$ ls foo.txt it244 work $ ls work $ mv foo.txt work $ ls it244 work $ ls work foo.txt
$ ls foo.txt hold it244 work $ mv foo.txt bar.txt $ ls bar.txt hold it244 work