Introduction to Unix Assignment:
We are going to be using panther over the course of the semester, so it is a very good idea to get comfortable with it as soon as possible. This assignment needs to be done on panther because its goal is to get good connectivity to panther.
Download your tools of putty (windows), and filezilla (both mac and windows). You can use the course setup page to find these.
You will now be following instructions to build a file, and then you will give that file to me through moodle. I called the file filename in my instructions, but you can call it whatever you like; however you have to be consistent and use that other name whenever you see filename.
Use putty or mac terminal to log into panther. You should be able to log in using your Adelphi universal password.
Create a folder for your classwork called csc271 (mkdir csc271)
Go into that directory with cd csc271
make a file that contains the date
date > filename
Next, you will create a bunch of files and directories and then add a listing of those files to that same filename.
- use ed to create a file that is 5-10 lines long. (see powerpoint from today's class on how to use ed. Start with ed and then a and then start typing your file contents. When done, type . and then w myFile)
- create a directory called hwk1 using mkdir hwk1
- Copy your file into that directory using cp (so now the same filename is in 2 directories) cp myFile hwk1
- cd into that hwk1 directory cd hwk1
- Copy the file in the hwk1 directory to another name using cp (so now you have 2 files with the same contents and different names in the hwk1 directory. cp myFile myFile2
- Use cat to check your work. (Use more and pr as well to see how they work to show your file.) cat myFile2
- Use cd .. to get back up to the csc271 directory.
- append a listing of the files in your csc271 directory to your original file: ls -lR >> filename
BE CAREFUL!! If you forget the second >, it will OVERWRITE YOUR FILE. (in which case, just redo the two commands that include >)
Add the contents of your original file:
- cat myFile>> filename
Choose a word that you will try to find inside your file (and it should exist in your file) and echo it into the file you are building:
- echo word to find is the >> filename
Next, you will grep the file you created to find all the lines that have a certain word (and you can choose the word). Add that grep to the file.
- First, use grep to find a word in your file that will show up on more than one line but not all lines
- Then, use that grep command to append to your filename: grep searchword myFile >> filename
Finally use ed to change one line in the file and append the entire file
- ed myFile
- pick a word to change
- s/oldword/newword
- wq to write and quit
- cat myFile >> filename
When you view (more) filename, you should see:
- date
- listing of all 3 files and the hwk1 folder
- contents of your file
- grep search of your file
- your file changed
This filename file needs to get back onto your computer so it can be uploaded to moodle. Use SFTP (filezilla) to transfer it back to your own computer. Then upload it to moodle's Intro to Unix assignment.
Here is a movie showing you how to copy your filename file from panther to your own computer so that you can upload it to moodle. If you have trouble with the first assignment uploading, I will not mark it late.