Tutorial Exercises Week 5

  1. Write a pipeline to show lines 7-10 of a file. Hint: use head piped into tail

  2. Baseed on the last answer, write a shell script that takes two parameters m and n and show lines m-n of the file

  3. Write a pipeline to show just the owners of files in the current directory

  4. Write a shell script to make a copy of all the files in the current directory into a directory $HOME/.backup

  5. Write a shell script to remove all the files in the current directory that end in ".bak"

  6. Write a shell script that takes all the files on the command line argument and makes a backup copy in the same directory ending in ".bak"

  7. Read the man pages for basename and grep. Look at the file /etc/mime.types. Write a command to list files in the current directory and display the file name and the corresponding mime type.
  8. Write a command display file which will take a filename as parameter and call an appropriate command based on its mime type. e.g. for a PDF file call evince file, for an application/msword file call ooffice file , for an text/plain file call vi file