Sedang Disiapkan

Bash Shell Script

I want to have four functions written in bash shell scripting

Function-1 (insert_record)

It will take four variables:

$name , which is will passed as an argument to the function.

The function may receive the name in one word as for example “smith” or two words or more like “Joy Smith Macline” in this case the function should replace the space with ‘_’ so it would be like $name=”Joy_Smith_Macline”

$Phone, which is will passed as an argument to the function, example $phone=”00123456789”.

$start_date, which the current date on the server but in the following format (hh:mm:dd:mm:yy).

$end_date, it would be a fixed variable which has a fix value ‘0’.

These values will be inserted into a file called “worklogs”

Sample file of worklogs:

Joy_Smith_Macline 00123456789 11:23:18:09 0

But if there is a record with same phone number and end_date=’0’, then it should break with error message, and if the record with the same number but end_date=(hh:mm:dd:mm:yy), then you can add the record.

Function2-Read _file

It will read worklog, and it will print only the records that has the value for $end_date as ‘0’ but also when it will show Joy_Smith_Macline as Joy Smith Macline that mean it will return the space in between words (on the screen only but in the file you should keep it as it, Joy_Smith_Macline).

So the output after calling this function on the screen:

Joy Smith Macline 00123456789 11:23:18:09 0


For this function you have to pass the phone number $phone as an argument .

Then the function has to open the file and search for the line that has the same phone number but with date_end=0, once it find it will replace it with current date and time (hh:mm:dd:mm:yy), notice that there might be more than one record with the same number, if the date_end=0 update it to the current date and ignore the one with end_date is define in the format (hh:mm:dd:mm:yy).

So as a summary if ($phone =001234567&end_date=’0’) then update

Else print error message.


You will pass the $phone as argument and you will check in the file if there is any record in the file with the same number and end_date=0 , if it’s there return 1 other wise return 0.

I want these functions to be ready within 12 hour and My budget for this task is 50$

Kemahiran: Linux

Lihat lagi: bash date operations, bash format number, bash date operation, bash script add numbers function, shell script break error, bash shell script, bash number format, find pass word, be smith, bash add numbers, adding time bash linux script, convert numbers thousands bash scripting, bash format error message, linux script bash, job bash shell script, shell number formatting, bash scripting yyyy, bash number date, unix bash script time format, bash date value, date operations bash, linux shell format string money, shell script creator, bash script global value example, bash date time

Tentang Majikan:
( 79 ulasan ) Sharjah, United Arab Emirates

ID Projek: #372734