Hey guy's....
I new here,
But im working on a school project, and I am not really good at programming. In fact, this is the only programming class that I need because programming is not what I am majoring in.
But I have everything done in this shell script except for this last part.....
Basically I have a file of an employee record book,
Formatted like so:
Firstname Lastname Phone OnCallDay
ex:
Henry Test 000-000-0000 Wed
There are more people in my file though. I have a shell script made to make changes to the record book. (add, delete records). But I need to add to my shell script, to let a person change a record's on call day.
It must only prompt the user for the person's name, and then the new on call day. It can not ask for the user's old on call day. So I really have no idea I would search for just a part of a line. Like is there is some way to just edit the last 3 characters of a given line?
Also two people cannot have the same on call day. (I have already figured this part out)
Here is that part of the script so far:
echo "Enter the name of the employee, to change their on-call day: "
read name
echo "enter new on call day: "
read newday
days=`grep $newday phonebook | wc -l` #This is to check availability day
if [ $days -ne 0 ]
then
echo "Sorry there is already an employee on call for that day"
exit
else
and this is where I would need to somehow pull the previous day (Mon,wed,Tue,Thu,Fri,Sat,Sun) out of a line and change it to the $newday. But I have no idea where to start
I know that I would start here by doing a grep to search for the person's line. But then I need to change the 3char on-call day of that line.....
Could anyone help me figure this last part out?
Any help would be greatly appreciated.....
Thanks a lot