Sponsored Content
Top Forums Shell Programming and Scripting Help edit simple payroll script? Post 302200754 by siba.s.nayak on Friday 30th of May 2008 02:08:04 AM
Old 05-30-2008
#!/bin/bash
# Script for figuring pay with overtime
# 5/28/08
hours=$1
normal=10
over=15
ntimepay=400
time=40
if [ $hours -le 40 ]
then
pay=`expr $hours \* $normal`
else
xtime=`expr $hours - $time`
pay=`expr $ntimepay + $xtime \* $over`
fi
echo "Total pay is $pay"
echo "done"





Quote:
Originally Posted by miss72006
I'm trying to write a simple script to figure pay with overtime...I got the first part to work, but I can't seem to get the second if statement's syntax right...SmilieI want it to take the 40 hours times 10 dollars, but then i want whatever is left over (like 7 of 47 hours) and take that times 15 dollars and then add the two figures...here's what I've got:
Code:
#!/bin/bash
# Script for figuring pay with overtime
# 5/28/08
hours=$1
normal=10
over=15
ntimepay=400
time=40
if [ $hours -le 40 ]
then
        pay=$[$hours*$normal]
        else
                if [ $hours -gt 40 ]
                then
                pay=$[expr $ntimepay + [$hours-$time]*$over]
                fi
fi
echo "Total pay is $pay"
echo "done"

Any help would be greatly appreciated! Thanks!Smilie
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

simple file edit

What command can I use to simply edit a file by searching for a word and then deleting the lines that I find that word in? (4 Replies)
Discussion started by: capesong
4 Replies

2. Shell Programming and Scripting

Simple SED edit

I have output like the following: B D 20070116095820001 N D S0000579.LOG S0000582.LOG B D 20070116095750001 N D S0000574.LOG S0000576.LOG B D 20070116095734001 N D S0000570.LOG S0000573.LOG B D 20070116095705001 N D S0000569.LOG S0000569.LOG B D ... (5 Replies)
Discussion started by: rdudejr
5 Replies

3. Shell Programming and Scripting

How to EDIT file using VI in a script

Hello, How would i go about editing a file using VI within a shell script please? Basically, i want to open a file, clear it's contents and save the file. I found this on the web using "ex" but can't seem to get it to work: ex /home/oconnor/TOOLS/UNIXCMDS/test_ex <<eof_ex dd /*i put... (2 Replies)
Discussion started by: bobk544
2 Replies

4. Shell Programming and Scripting

HP-ux: Script edit

Hallo Friends, I have written a script which goes through different directories deleting files but I think there is a shorter way I can do this please help. #!/bin/ksh #set -x cd /minotaur/Data/CFD_Input/E_CIF cd 051 for files in 2008* do rm -rf $file done # cd ../052 for... (3 Replies)
Discussion started by: kekanap
3 Replies

5. Shell Programming and Scripting

Need help in a shell script to edit a tablespace creation script.

Hi, CREATE TABLESPACE aps_blob_large01 DATAFILE '/c2r6u13/u03/oradata/qnoldv01/aps_blob_large0101.dbf' SIZE X 270532608 REUSE DEFAULT STORAGE (INITIAL 134217728 NEXT... (2 Replies)
Discussion started by: rparavastu
2 Replies

6. Shell Programming and Scripting

Script to make simple recurring ascii file edit

Hi, I have an ascii file with recurring lines (the file is 36mb so lots of lines) which look like this: -2.5 -66.324-68.138 935.2 1.953 -0.664 272.617 73.684 -2.428 269.998 0.000 Every 14 lines there is a blank line. I would like to, for each non-blank line,... (2 Replies)
Discussion started by: blueade7
2 Replies

7. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

8. UNIX for Advanced & Expert Users

File edit script exceptions how to pass to script

i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add ./script -- add hi ./script --add "hi how are you" now below script with case it is working for... (0 Replies)
Discussion started by: markjohn1
0 Replies
timetrans(3pm)						User Contributed Perl Documentation					    timetrans(3pm)

NAME
Net::DNS::SEC::Tools::timetrans - Convert an integer seconds count into text units. SYNOPSIS
use Net::DNS::SEC::Tools::timetrans; $timestring = timetrans(86488); $timestring = fuzzytimetrans(86488); DESCRIPTION
The timetrans() interface in Net::DNS::SEC::Tools::timetrans converts an integer seconds count into the equivalent number of days, hours, and minutes. The time converted is a relative time, not an absolute time. The returned time is given in terms of days, hours, minutes, and seconds, as required to express the seconds count appropriately. The fuzzytimetrans() interface converts an integer seconds count into the equivalent number of weeks or days or hours or minutes. The unit chosen is that which is most natural for the seconds count. One decimal place of precision is included in the result. INTERFACES
The interfaces to the Net::DNS::SEC::Tools::timetrans module are given below. timetrans() This routine converts an integer seconds count into the equivalent number of days, hours, and minutes. This converted seconds count is returned as a text string. The seconds count must be greater than zero or an error will be returned. Return Values: If a valid seconds count was given, the count converted into the appropriate text string will be returned. An empty string is returned if no seconds count was given or if the seconds count is less than one. fuzzytimetrans() This routine converts an integer seconds count into the equivalent number of weeks, days, hours, or minutes. This converted seconds count is returned as a text string. The seconds count must be greater than zero or an error will be returned. Return Values: If a valid seconds count was given, the count converted into the appropriate text string will be returned. An empty string is returned if no seconds count was given or if the seconds count is less than one. EXAMPLES
timetrans(400) returns 6 minutes, 40 seconds timetrans(420) returns 7 minutes timetrans(888) returns 14 minutes, 48 seconds timetrans(86400) returns 1 day timetrans(86488) returns 1 day, 28 seconds timetrans(715000) returns 8 days, 6 hours, 36 minutes, 40 second timetrans(720000) returns 8 days, 8 hours fuzzytimetrans(400) returns 6.7 minutes fuzzytimetrans(420) returns 7.0 minutes fuzzytimetrans(888) returns 14.8 minutes fuzzytimetrans(86400) returns 1.0 day fuzzytimetrans(86488) returns 1.0 day fuzzytimetrans(715000) returns 1.2 weeks fuzzytimetrans(720000) returns 1.2 weeks COPYRIGHT
Copyright 2004-2012 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details. AUTHOR
Wayne Morrison, tewok@tislabs.com SEE ALSO
timetrans(1) perl v5.14.2 2012-06-18 timetrans(3pm)
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy