Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Oct 2010
please help me to write this shell script
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.
(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.
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.
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.
Sorry, homework questions are not allowed by the forum rules.
But here you should find explanation and examples of all tools neded for your tasks.
Advanced Bash-Scripting GuideYou must always face the curtain with a bow.