The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How To Calculate krishna_sicsr Shell Programming and Scripting 3 03-21-2009 01:49 PM
calculate the space za_7565 Shell Programming and Scripting 8 05-04-2008 07:22 AM
how to calculate CPU time under HP-UX limame HP-UX 1 06-18-2007 05:28 PM
How to calculate with awk whatisthis Shell Programming and Scripting 4 11-09-2005 12:39 PM
bc calculate problem Nicol UNIX for Dummies Questions & Answers 2 09-13-2004 10:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-12-2006
amon amon is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 71
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...
  #2 (permalink)  
Old 04-12-2006
JunkYardWars JunkYardWars is offline
Registered User
  
 

Join Date: Mar 2006
Location: Gurgaon
Posts: 26
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
  #3 (permalink)  
Old 04-12-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
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
  #4 (permalink)  
Old 04-12-2006
amon amon is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 71
Thank to both of U...I am beginner in shell programming but I figure how scripts work...

THANKS again
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0