November 25, 2024, 05:08:38 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Linux shell scripts  (Read 6710 times)

Offline Kane

  • New Member
  • Posts: 1
Linux shell scripts
« on: October 09, 2010, 11:26:02 AM »
Anyone help me with this?

Task A:
Find all log files (with extension .log) in /var/log (no subdirectories) and copy them to the directory systemlogsOct13 in the home folder of the root user. The suffix Oct13 of the name of the directory should be generated by the script, and represent the date the script is run. If the directory does not exist then create it, otherwise add to the existing contents. Make sure you don’t overwrite files with the same name; work with unique names in the systemlogsmmmdd directory.

Task B:
(uses the result of Task A)
Produce a report on screen that holds the following information: The difference in number of files and disk space between the systemlogsmmmdd directory and the log files in the /var/log directory, The number of files in systemlogsmmmdd that had to be renamed when these were copied.
Then ask the user if the contents of systemlogsmmmdd need to be deleted, and act accordingly. The suffix mmmdd represents the current date, as in Task A. If systemlogsmmmdd does not exist it still produces a report that makes sense.

Task C:
Find all files within the /home folder (including subfolders), belonging to a chosen user that are not in that user’s home folder. The chosen user’s name is to be prompted and entered from the keyboard. Verify that the user's name is not empty, and that the user's home folder exists. If the user’s name is username, you may assume that the user’s home folder is /home/username, if it exists.

Task D:
Create a compressed tar archive of a chosen user’s home folder, and save this file in the /home directory. Make sure the name of the archive relates uniquely to this user. Add to the file called archivestats in /home information about the number of files in the tar archive, and the size of the archive before compression. If archivestats does not exist then create it, otherwise append to the existing contents. After archivestats has been updated it should be presented on screen, one page at a time. The chosen user’s name is to be prompted and entered from the keyboard. Verify that the user's name is not empty, and that the user's home folder exists. If the user’s name is username, you may assume that the user’s home folder is /home/username, if it exists.