Shell Exercises - 2

  1. Write a shell script called lsdirs which lists just the directories in the current directory (test).
  2. Write a shell script that takes a uid as an argument and prints out that person's name, home directory, shell and group number. Print out the name of the group corresponding to the group number, and other groups that person may belong to. (groups, awk, cut. Also look at /etc/passwd and /etc/groups).
  3. Write a script that reads each line of input from a file and writes it to a target file but with an extra blank line after each line. This is creating a double line spacing of the file.
  4. Given a process ID (PID) as input, write a script that checks whether the process is still running or not. (hint: use ps and sleep commands)
  5. List all files whose size is larger than a given size in a given directory.
  6. Check the disk usage of a user and print a message "WARNING: Disk usage exceeding quota value" where quota is the value given as a parameter and the user name is also a parameter to the script.