shell script to seperate male employees from female employees
Write shell script to enter the information of company employees until the user enter 0 for employee’s id .The information is
(Id , name , sex (M, F) , total hour worked in a month)The script will list the information of all Males employees and females’ employees in two separate files named Males and Females and the total number of Males and total number of Females with average total hours worked for each with final result message ex. “The productive of males is better” or “The productive of females is better”. I just started using linux and all i came up with is this -record (employee, {id, name, sex, total-hours}) and i'm not even sure of it |
Sounds like a homework assignment here. So in order to point you in the right direction so you can get this done we will need some more info.
Your script will read data, test it, and then output based upon the results of that test. Is the data going to be read from a flat file or will the user be prompted to enter this information into the script and have it be stored as variables? If its a flat file what is the structure of the file, is it comma delimited, space, etc.. Not sure what this is: -record (employee, {id, name, sex, total-hours}) |
the user is suppose to enter the information and it should look like a table with 4 columns (Id , name, sex, total hours)
|
And the user is entering this information on the command line correct? Have you made any progress besides the one line posted above?
Also are you going to be coding this in a bash script or some other language? |
yes, on the command line and i'm not really sure if i should use the bash script, but most likely,yes
|
I'll help you out here do you mind telling me if this is a homework assignment(I will still help you if it is). If this is homework I'll go into more depth and give you so good links to bookmark for future reference.
I use the analogize Linux to being a Chef quite often. Anyone who owns a betty crocker book can become a decent chef, similary in Linux if you know where your resources are and how to read them you can become a decent Linux scripter/user/admin. |
it's a bonus question ...like if i did it, then it'll be great and if not, it'll be fine
but i really wanna know how to do it.. |
You'll want some good bash reference material.
Here's a good tutorial http://rute.2038bug.com/index.html.gz Ref/tutorials on each cmd by example http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ Notes: 1. do put the cmds into a file aka bash shell script file 2. have a good look at the 'read' cmd 3. when you've got something, if you get stuck, post it here and explain what issues you are having. 4. for debugging, add 'set -xv' near the top of your script eg Code:
#!/bin/bash |
I'm sure the links and notes will help me, thx a lotttt Chris...
|
Those are some great links to have. Chrism01 also gave you a good starting point. I'll give you a small snippet of one of my own codes here that reads a value and stores it as a variable as well as tests the variable for the correct type of input. Hopefully this will give you an idea of what you're trying to accomplish.
Code:
echo "Please enter the number of employees to enter" #Print output to the user asking them a question A good link for if statement reference: http://tldp.org/LDP/Bash-Beginners-G...ect_07_01.html And here's the specific chapter for writing interactive scripts that I would suggest you read before getting started. http://tldp.org/LDP/Bash-Beginners-G...l/chap_08.html Let us know if you have any specific questions or errors while going through this. Welcome to the wonderful world of Bash. |
can any one write the full code please?
|
We aren't going to write it for you. Its the old teach a man to fish analogy. Read over the information provided and you should have no problem writing this for yourself. If you get stuck or need info on something specific let us know and we will help you out.
|
All times are GMT -5. The time now is 12:57 AM. |