CS257 Lab: Unix Miscellany

Nothing to hand in--just do these things.

There are a bunch of questions that start with "What command or combination of commands would you use to...". Try to answer these with commands that fit on a single line without semi-colons.

You may find the following standard Unix commands handy in some of these questions: grep, tr, sed, sort, and find.

  1. If you feel uncomfortable with Unix, walk through this Unix tutorial from the University of Surrey. It may be mostly or all review for you, but I want to make sure we have a common vocabulary of basic Unix ideas. No need to hand anything in for this.

  2. What are "System V" and "BSD"? What, if anything, is their relatioinship?

  3. What is POSIX? What's the relationship between Unix and POSIX?

  4. Suppose you want to see the effects of "ls -aF" whenever you execute the "ls" command (that is, you want "ls" to default to using the "-a" and "-F" options). How can you arrange this for your Math/CS account? [This is a question about "aliases" and how they can be created in a suitable "rc" file. If you are using some version of the C-shell, you will need to put your alias command in your .cshrc file. If you are using bash, you will use the .bashrc file instead.]

  5. If you want your Math/CS account $PATH environment variable to include the current directory (".") whenever you log in, what should you do? [Again, this will lead you to modify your .cshrc or .bashrc file.]

  6. What are the advantages and disadvantages of putting "." at the beginning of your $PATH environment variable, versus at the end of $PATH, versus not at all?

  7. What command or combination of commands would you use to remove all the carriage returns (ASCII 13, also known as '\r') from file.txt?

  8. What command or combination of commands would you use to change all linefeeds to CRLF pairs (carriage-return followed by linefeed). Why would you want to?

  9. What command or combination of commands would you use to count the number of blank lines in the file file.txt?

  10. Suppose you wanted to copy the HTML source of the Google home page to a file called google.html. Show how you would do it using lynx, using wget, and using curl.

  11. What command or combination of commands would you use to count how many files in your account have names that contain the string "moose", regardless of case. (Thus, if you have smoose.txt and schmOoSe.txt, they should both be counted.)

  12. What command or combination of commands would you use to print the complete list of the "moose" files in your account, sorted in reverse alphabetical order?

  13. What command or combination of commands would you use to print all occurrences of the word "moose" in all of the files in your account? You may provide a solutions that is case sensitive or not, as you wish.





Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu