Fall Semester 2000
For each of the following exercises create a text file with your answer. See Exercise 5, below, for instructions on submitting your homework.
Using the Gnu emacs editor, write a text document describing your experience with physics and with computers. Specifically, please list (by name, not number!) the physics courses which you have taken or are taking--if you are a graduate student then list only those courses which will appear on your graduate transcript (i.e., do not list courses taken as an undergraduate). Also please list the operating systems and computer languages (e.g., C, F90, Mumps) with which you've had experience and indicate the length of time you've worked with each one. This exercise is partly designed to help the instructor determine the level of expertise of the class, but the real (i.e., graded!) intent is to introduce emacs.
Save your textfile using the name exper.txt.
This exercise will introduce a little of how you can customize your shell.
When you shell starts up, it looks at a file called .cshrc ("dot-sea-shark"), located in your home directory. This generally tells your shell various things like what kind of terminal you are using, the location of man-page files, etc. In the Department of Physics, this file is setup to automatically read other files which the system manager maintains to keep up with hardware and software changes. You SHOULD NOT modify your .cshrc file.
Your .cshrc file does allow you to costumize your shell by incorporating (via the "source" command) a file which you can create and edit, called .customs.cshrc (this is specific to the Physics systems, not to the Un*x world at large). Here, you will create a .customs.cshrc file.
In this exercise you will do the following thing: First, create file called .mytips (a hidden file) in your home directory. Make the file's contents so that each non-blank line begin with a subject (e.g. a unix command) followed by a phrase, e.g.,
This file is a good place to keep notes to yourself; by typingcat: dumps the contents of a file to std output. cat: you can create a file by redirecting cat's output to std input cat: when dumping std input to a file with cat use ^D when done. emacs: ^G aborts commands, try it when things seem to go awry.
grep cat: ~/.mytipsyou can print out all the lines in the file .mytips which contain the word "cat:". This way you can easily extract information about a particular command or feature of your local system.
Next, create a second hidden file called .aliases, also in your home directory. This file contains a list of so-called aliases, which allow you to use a command of your choosing to execute one or more other shell commands. (See the man pages for the shell command alias.) Modify this file so that you create an alias mytips which, when run as in
mytips catit does the grep command as given above. Specifically insert the line
alias mytips 'grep \!* ${HOME}/.mytips'
into your .aliases file. To try the effect of this, you can either
type that line directly as a shell command.
Then try typing "mytips cat".
The final step in all this is to create a .customs.cshrc file by copying ~p5720/examples/dot-customs.cshrc to your home directoy, but call it .customs.cshrc. This file contains instructions that modify your shell's behavior, and includes some features which will be helpful in this course. At the very end of this file, add the line
if ( -e ~/.aliases) source ~/.aliases(the source command reads in the file .aliases and executes the contents of the file as if you typed them in yourself).
NOTE: on physics systems, your .aliases file gets sourced by default (a file called /usr/local/skel/physics/SYS.cshrc gets sourced by your .cshrc and this in turn sources your .aliases file.) This is a common but not standard procedure. For example, on math systems, your .aliases does not get sourced unless you put in the above command explicitly in your .cshrc (or .customs.cshrc) file. An important ramification for this exercise is that any mistakes in the .aliases file will cause HIGHLY INCONVENIENT problems even if your .customs.cshrc is set up correctly.
When modifying the .customs.cshrc file, be sure
to try these two commands:
to see if all is well. If the response to either one is anything but
a nice new prompt, DO NOT log out of X windows! If something
is broken, you will be unable to start up X windows.
You MUST fix whatever is wrong, or rename (or delete) BOTH
your .customs.cshrc and .aliases files!!!
source ~/.cshrc
tcsh
Now, whenever you log on, the mytip alias will be in place, along with the others listed in your .aliases file.
Submit three files for this exercise, using this naming convention: dot-customs.cshrc, dot-aliases, and dot-mytips. The submit utility for this class refuses to accept hidden files, so for the purposes of handing in the exercise please copy your ".*" files to "dot-*".
a) cd ~ && du -k | sort -r -n | mail `whoami`
Note: the quote-marks are "back-quote" characters. (This may help one to be a "good citizen" on a system where disk space is tight. Thanks to WK.)
b) ps aux | grep `whoami` | awk '{print "kill", $2}' | sh -s
(Be careful with this one--it is not a nice thing to do. Substitute echo for kill, perhaps, in order to guess what it does without actually running it. Note that it will have somewhat erratic behavior (it may sometimes appear to to nothing)--if you know why, explain.
c) cat file2 file3 | tee file4 | grep baboon
Submit your answers in a textfile called unix.txt.
In ~p5720/data there is a file called lcrs.bright_gax containing a list of data from galaxies observed in the Las Campanas Redshift Survey. It is a 4 column text file except that the first few lines contain comments; the first column is recession velocity (km/s), the second two are polar angles theta and phi, the last is Absoluted Magnitude in red light. In what follows, treat recession velocity v as a radial distance so that the first three columns describe spherical coordinates in a 3D space, with the origin at the sun. (To get an approximate real distance, just divide v by the Hubble parameter, believed to be around 60-80 km/s/Mpc, where 1 Mpc = 1 megaparsec = 3.086x10^24 cm.) Note that absolute magnitude is a measure of the intrinsic brightness or luminosity (emitted energy per second) of a galaxy. For historical reasons, more negative numbers mean brighter objects.
Use grep to strip off all lines containing comments (hint: check out grep's -v option) and to create your own purely numerical data file. Then use sort (and whatever else you want) to find
a) the smallest and largest recession velocities, and
b) the recession velocities of the brightest (most negative Absolute Magnitude) and faintest galaxies.
c) The data were taken from a survey that used flux limits to determine which galaxies were to be observed. This means that galaxies had to have an observed brightness which was brighter than a certain threshold in order to be included in the survey. Are your results in part b) consistent with this fact? Just a qualitative answer is sufficient.
Put your answers to parts a-c in a text file called galaxies.txt.
This exercise tells you how to hand in your homework (following closely an assignment from R. Price). No credit will be given for any of the above exercises if this last one is not completed--please let us know if you have trouble!
Please follow the instructions given here in the assignments web page.
The files to be submitted for this assignment are