![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calculate the space | za_7565 | Shell Programming and Scripting | 8 | 05-04-2008 04:22 AM |
| how to calculate CPU time under HP-UX | limame | HP-UX | 1 | 06-18-2007 02:28 PM |
| How To Calculate | krishna_sicsr | Shell Programming and Scripting | 1 | 03-28-2007 07:24 AM |
| How to calculate with awk | whatisthis | Shell Programming and Scripting | 4 | 11-09-2005 08:39 AM |
| bc calculate problem | Nicol | UNIX for Dummies Questions & Answers | 2 | 09-13-2004 07:21 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
calculate output
I was wondering can anyone give me a clue how to start script which would do the following:
I have 2 numbers as input for example: 100 and 1000 and I need to create file and in that file should be written 100 - 199 200 - 299 300 - 399 400 - 499 500 - 599 600 - 699 700 - 799 800 - 899 900 - 999 U can guess if I have 100 as a number and 100 000 as b number how would it like... should I start with awk or... thanks in advance... |
| Forum Sponsor | ||
|
|
|
|||
|
Input 1- 100
Input 2 -1000 hope thats what u wanna do.... #! /bin/ksh typeset -i ranger=$1 typeset -i mark=$2 typeset -i range=`expr $ranger - 1` while [[ $ranger -lt $mark ]] do echo "$ranger "-" `expr $ranger + $range`" ranger=`expr $ranger + $range` ranger=`expr $ranger + 1` done |
|
|||
|
Code:
#! /usr/bin/ksh if [ $# -ne 2 ] then echo "<script> first second" exit 1 fi first=$1 second=$2 INTERVAL=$1 while [ $first -lt $second ] do echo "$first---$(($first + $INTERVAL - 1))" first=$(($first + $INTERVAL)) done exit 0 |