Set 5
Home Up Introduction Set 1 Set 2 Set 3 Set 4 Set 5 Set 6 Set 7 Set 8 Set 9 Set 10 Set 11

 

File Manipulation

  1. What does this sequence of commands do?  Do the two mv commands cancel each other?
  2. $ date >datefile
    $ mkdir pluto
    $ mv datefile pluto
    $ mv pluto datefile
  3. Why do I get an error message here?
  4. $ date >newdatefile
    $ cat newDatefile
    cat: cannot open newDatefile
  5. Show a Unix command pipeline that will count how many Unix manual pages have the word "file" in their descriptions.  (Hint: Using the correct option to the man command will get you half-way there.)
  6. An option to the cat command will number the output lines.  Show a Unix pipeline that will display the line number and lines from your .profile file that contain the word if .  (The output should include the line number of the line containing the if as well as the line itself.)
  7. The sort command, like many Unix commands, will read from standard input if you don't give it a file name to sort.  Explain why the output of the following sort puts 2 after 10.   Which option to the sort command will sort the numbers correctly?
    $ sort
    1
    2
    10
    20
    ^D   (this ^D means you type control-D, signalling End-Of-File [EOF])
    Output:
    1
    10
    2
    20
  8. In class we developed a Unix pipeline that created class EMail addresses followed by names by using ypcat and the awk program.  Modify the pipeline so that the name comes first, followed by the EMail address.  Show the new pipeline and the first few lines of the output.
  9. How many lines contain the word font in the html source for the Problem Set 4 web page?  Explain how you found this out.
  10. What Unix command will tell you if two files have the same content?  Give an example of its use.
  11. What Unix command will tell you if two files are really the same file (the two names actually point to the same data)?  Give an example of its use.
  12. Give a Unix pipeline that will show the five most recently modified files in the current directory.
  13. Give a Unix pipeline that will show the five least recently accessed files in the current directory.
  14. Answer this question using vi on a Solaris computer. Create a file with the word "Here" in it in your home directory.  Start up vi, editing this file you just created.  Change "Here" to "There" but don't save the file yet.  Use the cd command inside vi to cause vi to change to the /tmp directory.  Now exit vi and save the buffer using ZZ .  In which directory did vi save the file?  Use the ls command and the cat command to show the date and contents of each file.  (Use cut and paste from you terminal window to demonstrate what happened.)
  15. Answer question 12, this time using vi (or vim) on a Linux computer.