This assignment will give you an overview of the UNIX shell. The shell is your basic means of interaction with the system. Because you are using a cs9e account, we have customized your shell for use in this course. Shell accounts that you have on other systems and for other classes will more than likely look slightly different, but they all behave similarly. This assignment will teach you how to use the shell and how to customize it for your own needs.
Das: Ch. 7, 9 (excluding 9.10), 10
Use 'script' (Section 2.8) to record your session, so you can show it to a tutor.
Perform the following operations, and be prepared to explain the commands you used to a tutor in addition to recording them in your transcript.
From within your home directory, perform a ls operation shows all directories that begin with a ".". You should not see plain files, and you should not see the contents of these directories. Example:
~ $ ls _____________ ../ ./ .ssh/ .ssh2/ .sunw/ .tin/
Use quoting or escaping where necessary (and only where necessary) to properly create directories with the following names:
IE, if you do an ls, you should see:
$ ls -a !*\ - . .. ... $HOME "What's For Dinner?"
List all files in /usr/bin which begin with the letter a, b, or c.
Echo every 2 letter combination of a, b, c, and d including doubles. IE:
$ echo __________ aa ab ac ad ba bb bc bd ca cb cc cd da db dc dd
Make the necessary changes to your shell configuration files to do the following. You will need to show the results as well as the changes to your tutor for checkoff. After being checked off, feel free to undo these changes.
The file ~${MASTERDIR}/hw/01.02-shell/al.batters.88 contains the Final Official 1988 American League batter statistics. The "position" category lists positions at which the player played 20 or more games. Each line of the file contains the following information about a player, organized into fields separated by one or more blanks:
- his name
- his team
- his position or positions
- whether he bats right-handed or left-handed
- his batting average (hits divided by at-bats)
- the number of games he played
- how many "at bats" he had
- how many runs he scored
- how many hits he had
- how many total bases he had (1 for each single, 2 for each double, etc.
- how many doubles
- how many triples
- how many home runs
- how many runs batted in
- how many sacrifice hits
- how many sacrifice flies
- how many times he was hit by a pitch
- how many walks
- how many intentional walks
- how many times he struck out
- how many stolen bases
- how many times he was caught stealing
- how many double-plays he hit into
- his on-base-average
Use piping and UNIX commands you have learned about to answer the following questions. Be prepared to explain the commands you used to a tutor in addition to recording them in your transcript.
You may assume that there is at least one AL player who hit no home runs in 1988, that at least one player ranked in the top ten both in batting average and in the number of home runs, and that at most one player with a given number of home runs also has one of the top ten batting averages.
Note the difference between sorting twice and sorting on two keys. Your pipeline will run more efficiently if head appears as early in the pipeline as possible. (Why?)