مساعدة يا شباب عندي بعض المسائل مطلوب كتابة shell script
1) Write a script that takes a single command line argument, the login name of a user, and checks to see if that user is logged in. If the user is logged in the script should output "User xxx is logged in", if the user is not logged in the script should output "User xxx is not logged in" - where xxx is the login name of the user. If the user forgets to type the single argument an appropriate error message should be issued from your script.
2) Write a script, with no command line arguments or user input, whose output will be a function of the time of day the script is executed. If run between midnight and noon the script will output "Good morning, xxx", if run between noon and 6pm the script will output "Good Afternoon, xxx", and if run between pm and midnight the script will output "Good evening, xxx". Where xxx is the login name of the user.
3) Write a script called junk which takes one or more file names as arguments. The script should move each of the files specified to a subdirectory called .junk in your home directory. If the subdirectory does not exist the script should create it. The script should output to the screen the name of each file moved as well as the total number of files moved.
4) Write a script that manages a telephone directory(file). Each entry in the directory will contain first name, last name and telephone number. The script should be called "tel" and have the possible command line commands and arguments -
tel -a Harry Jones 521-2703 where -a means add the following first name, last name and telephone number to the directory
tel -f Jones where -f means find the entry for the last name and display it
tel -d Jones where -d means delete the entry for the last name
tel -s where -s means displays the directory sorted by last name
Your script should handle all error conditions gracefully i.e. invalid number of arguments, missing file, invalid option etc.
Here are some hints
- use positional arguments i.e. $1, $2 etc. to refer to the arguments on the command line
- use $1 to drive a case statement for the different options
- in order to write to the directory file use input and output redirection where the input comes from a string of variables specified on the command line and the output is the directory file called telephone
- refer to the man pages for the grep option which will allow you to delete lines containing a string, or rather copy all lines that don't have a specific string
بليز مساعدة .... موشرط كلهم اي وحدا فيهم
وشكرااااااااااااااااااااااااااا