Tutorial Sheet 2.doc

advertisement
CST334
TUTORIAL SHEET 2
1. BASIC FILE MANIPULATION
INTRO TO UTILITIES
(commands are in bold, arguments are in italics)
Copy a file
cp old_file new_file
Print a file
Look at the top of a file head file
Display a file in alphabetical order sort file
Test a file's contents
file file_name
Re name a file
mv old_name new_name
Search a file for 'hello' grep 'hello' file
Look at the end of a file
Compare two files diff f1 f2
Delete a file
rm file
2. MISCELLANEOUS
echo Repeats whatever you type-- for reasons to be explained later
date gives you the time and date
cat
Concatenate--displays multiple files sequentially without interruption (cat f1 f2 f3 )
Allows you to merge several files into one (cat f1 f2 f3 > f_all) ( more about > later)
3. BASIC FILE COMPRESSION
Compress a file
gzip -v file
Uncompress a file
gunzip file
Check what type a file is file file_name
Tells you how much it compressed
4. FINDING UTILITIES AND HELP
Tell which version of a utility you are using
Where other versions may exist
Find utilities that can help you with a task
Two ways to get information on a utility
Select a menu item in info
Auto-Completion
which utility (example which ls, which gzip)
whereis utility
apropos utility
man utility, or info utility
M, first letters, tab-key completes
tab-key (In general, completes your file names)
5. COMMUNICATING ONLINE
Find out who is logged in
who or w
Send a message to a user's screen
write user_ID (for example mpc80aXX)
Reply to someone else's message
write their_user_ID
Stop a communicating session
^D
Stop people from displaying messages on your screen (*exercise)
mesg n
6. EMAIL
Find out if you have any message
pine
Check your in box
i (index)
Read a message
Highlight message with arrow, then type enter.
Send a message
c (compose)
Save an attachment
> (view attachment)
Attach a file
^j enter file name
Return to menu
m
LABORATORY
Always read the response on the next line after you type a command!
If you get an error, you must redo the command. CHECK YOUR SPELLING
Log into mlc104
make three copies of your bio file: bio1, bio2, bio3
Change the name of bio3 to bio.old
Read the Unix manual entry on Joe
Edit bio2 using Joe
With one keystroke, delete the second line
Save the buffer to file: bio.mod
Exit Joe
List the contents of your directory
Display the contents of your new file
Compare the two files bio and bio.mod (diff)
Concatenate the contents of file bio and food, and put into bio.mrg
Delete bio1 and bio2
copy a file from the group directory
cp ../trebold/cst334/mars.txt .
(. is important!)
Examine (read) the file mars.txt
Compress the file mars.txt (how much did you compress?)
Check the type of contents using the file command
Un-Compress the file and then display using cat. Did it change?
Start a dialogue with your neighbor using write
Send an email to your neighbor using pine
When you are finished, you can get assignment 2 by typing
Exit Unix by using the exit command never just kill ssh unless Unix is not responding
Log out from your PC
Download