Sponsored Content
Full Discussion: calculate output
Top Forums Shell Programming and Scripting calculate output Post 302071093 by JunkYardWars on Wednesday 12th of April 2006 07:44:27 AM
Old 04-12-2006
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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bc calculate problem

Hi , this is the first time i use bc to calculate and i would have decimal result , i use the following : toto=400;scale=1 echo $toto / 1000|bc scale to adjust the numbers after the command would have in this case 0.4 as result and i wonder why i have always 0 as result. Somebody can... (2 Replies)
Discussion started by: Nicol
2 Replies

2. UNIX for Dummies Questions & Answers

calculate the time

hello i want to display the time firstly when i run my shell script and after 25 min i want to display a message it says that the time left is 5 min. When the calculated time is 30 mins, the script should exit. can any one help me with that! Thanks in advance Regards :o (5 Replies)
Discussion started by: dndoon
5 Replies

3. Shell Programming and Scripting

How To Calculate

I have 2 variables in my shell scripts in which i am using awk and calculating 2 files and getting 2 different variable called in_total and out_total. I want to subtract one variable from another so plz tell me how i can do that. Example is: cat in_file | awk -F: '{ in_total += $1 * 86400... (3 Replies)
Discussion started by: krishna_sicsr
3 Replies

4. Solaris

how we can calculate this bytes(55207936) in to MB(output=26957)

root@erpdevserver $ vxassist -g devdg maxsize Maximum volume size: 55207936 (26957Mb) This is the output in vxvm(3.1).. my question is how we can calculate this bytes(55207936) in to MB(output=26957) or in GB.plz tell how to calculate (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

5. Shell Programming and Scripting

Formatting output so I can calculate time difference between two stamps

I know there have been a million questions regarding calculating time stamps, and with enough googling, I think I'm almost there (I'm going to use the changing the times into seconds and subtracting solution). My problem is that I'm not sure how to format my log file to get the info I need. Below... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

6. Shell Programming and Scripting

Calculate N days from a file output

OK, here is the output from a cron I have here: FULL OUTPUT: acoxxx Lastlogin= 2010/07/15 13:10 db2t Lastlogin= 2010/07/16 13:09 db2tadm Lastlogin= 2010/07/20 13:09 eisuser Lastlogin= 2010/07/20 11:53 israel Lastlogin= 2010/07/10 11:42 nmon Lastlogin= 2010/07/05 12:55 norbac Lastlogin=... (4 Replies)
Discussion started by: iga3725
4 Replies

7. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

8. Shell Programming and Scripting

awk to calculate timex output

I have a timex 'dd' command that generates an output similar to this: real 701.92 user 3.06 sys 469.10 for the moment, i m redirecting the output to a temp file to stage the calculation (using bc) for: a) MB/s b) cpu usage = 100*(user+sys)/real I am looking around for an 1-liner... (3 Replies)
Discussion started by: ux4me
3 Replies

9. UNIX for Dummies Questions & Answers

Calculate

i have file input abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31 fsdasdf|ferg|12|04|25|21|21|A1|13|02|26|20|31 dfsfsad|gerg|12|04|25|21|21|A1|13|02|25|25|31 i expect the output abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31|9.516666667... (5 Replies)
Discussion started by: radius
5 Replies

10. Shell Programming and Scripting

Bash to calculate average of all files in directory and output by part of filename

I am trying to use awk to calculate the average of all lines in $2 for every file in a directory. The below bash seems to do that, but I cannot figure out how to capture the string before the _ as the output file name and have it be tab-delimeted. Thank you :). Filenames in... (3 Replies)
Discussion started by: cmccabe
3 Replies
FBB::Ranger(3bobcat)						   Error handler					      FBB::Ranger(3bobcat)

NAME
FBB::Ranger - generalizes ranges for range-based for-loops SYNOPSIS
#include <bobcat/ranger> DESCRIPTION
The Ranger class template defines ranges that can be used with range-based for-loops. The standard range-based for-loop requires for its range-specificiation an array or an iterator range as offered by, e.g., containers (through their begin and end members. Ranges defined by a pair of pointers or by a subrange defined by iterator expressions cannot currently be used in combination with range-based for-loops. Ranger extends the applicability of range-based for-loops by turning pairs of pointers, an initial pointer and a pointer count, or a pair of iterators into a range that can be used by range-based for-loops. Ranger is a class template requiring one template type parameter: Iterator, an iterator or pointer type reaching the data when derefer- enced. Ranger's users don't have to specify Ranger's template type. The function template ranger returns the appropriate Ranger object. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. FREE FUNCTION
When using the following free functions, any (subrange) of iterators or pointers can be used. With iterators subranges of reverse iterators can also be specified. The EXAMPLE section below illustrates the use of the ranger function templates. o Ranger<Iterator> ranger(Iterator &&begin, Iterator &&end): this function template returns a Ranger object for the (sub)range defined by two (reverse) iterators; o Ranger<Iterator> ranger(Iterator &&begin, size_t count): this function template returns a Ranger object for the (sub)range defined by the (reverse) iterator range begin and begin + count; o Ranger<Data *> ranger(Data *begin, Data *end): this function template returns a Ranger object for the (sub)range defined by the two pointers begin and end; o Ranger<Data *> ranger(Data *begin, size_t count): this function template returns a Ranger object for the (sub)range defined by the two pointers begin and begin + count. CONSTRUCTORS
Below, Iterator refers to the Ranger class template's type parameter. Although named 'Iterator' it can also be a pointer to some data type (e.g., std::string *). o Ranger(Iterator const &begin, Iterator const &end): A Ranger object can be passed as range-specifier in a range-based for-loop. All elements defined by the range will subsequently be visited by the range-based for-loop. The copy and move constructors are available. OVERLOADED OPERATORS
The copy and move assignment operators are available. MEMBER FUNCTIONS
o Iterator const &begin() const: returns (a copy of) the begin iterator passed to the Ranger's constructor. Note that if Iterator was a pointer type (like int *) the data to which the iterator returned by begin() can actually be modified, as the member's return type (using int * for Iterator) becomes int * const &, so a reference to a constant pointer to an int. This is perfectly OK: if the data themselves should be immutable, then the data type must be defined as int const, which is automatically the case when passing int const * data. See the EXAMPLE section for an illustration. o Iterator const &end() const: returns (a copy of) the end iterator passed to the Ranger's constructor. If reverse iterators are passed to Ranger's constructor, then the begin and end members return reverse iterators. Since the intended use of Ranger objects is to define a range for range-base for-loops, members like rbegin and rend can be omitted from Ranger. EXAMPLE
#include <vector> #include <iostream> #include <bobcat/ranger> using namespace std; using namespace FBB; int main() { vector<int> iv {1, 2, 3, 4, 5}; // display and modify a subrange for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el++ << ' '; cout << ' '; // display a reversed range for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el << ' '; cout << ' '; // same: display using a count for(auto &el: ranger(iv.rbegin() + 1, 3)) cout << el << ' '; cout << ' '; int intArray[] = {1, 2, 3, 4, 5}; // display and modify elements // in a pointer-based range for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el++ << ' '; cout << ' '; // data now modified for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el << ' '; cout << ' '; // using a count rather than an // end-pointer for(auto &el: ranger(intArray + 1, 3)) cout << el << ' '; cout << ' '; int const constInts[] = {1, 2, 3, 4, 5}; // data can't be modified for(auto &el: ranger(constInts + 1, constInts + 3)) cout << el << ' '; cout << ' '; } FILES
bobcat/ranger - defines the class interface SEE ALSO
bobcat(7) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::Ranger(3bobcat)
All times are GMT -4. The time now is 01:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy