Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Copy last few lines of a file, perform math operation and iterate further Post 303031218 by RudiC on Sunday 24th of February 2019 04:33:06 AM
Old 02-24-2019
Hi SaPa,


thanks for sharing your working (!) approach.
Pls be aware that it contains elements that were not specified in post #1 and thus could not be covered by the proposals given. Also, running 3 external commands in extra processes, plus 4 file operations (open), for each of the 639 iterations might not be the most efficient usage of resources.


@nezabudka: Thanks for your "exotic" approach, giving me and my aspects / perspective / tool box a new dimension!
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to perform arithmetic operation on date

Hi all, I would appreciate if anyone knows how to perform adding to date. As for normal date, i can easily plus with any number. But when it comes to month end say for example 28 Jun, i need to perform a plus with number 3, it will not return 1 Jul. Thanks in advance for your help. (4 Replies)
Discussion started by: agathaeleanor
4 Replies

2. Emergency UNIX and Linux Support

Logic for file copy operation

Hi, i need to copy contents from source to destination with a few conditions, Please helpme out. Sample input file $>cat testfile.txt /a/b/c/d | /e/f/g/d (d can be either a file or directory) my conditions are: check if destination is valid and if its a file or directory if its a... (5 Replies)
Discussion started by: raghu_shekar
5 Replies

3. Shell Programming and Scripting

Enter third column & Perform Operation

I am trying to enter a third column in this file, but the third column should that I call "Math" perform a some math calculations based on the value found in column #2. Here is the input file: Here is the desired output: Output GERk0203078$ Levir Math Cotete_1... (5 Replies)
Discussion started by: Ernst
5 Replies

4. Shell Programming and Scripting

awk math operation on two files

Hi, I need your help. I've got two files and i need to add 2nd line after occurrence of "Group No X" from data2.txt to 3rd line (after occurrence of "Group No X") from data1.txt. There is the same number of "Groups" in both files and the numbers of groups have the same pattern. data1.txt Group... (2 Replies)
Discussion started by: killerbee
2 Replies

5. Shell Programming and Scripting

[Solved] Perform an operation to all directories

Sorry, about this thread - I solved my own problem! Thanks for taking a look. edit by bakunin: no problem, but it would have been a nice touch to actually tell us what the solution was. This would have been slightlich more educating than just knowing that you found it. I changed your title to... (0 Replies)
Discussion started by: Blue Solo
0 Replies

6. Homework & Coursework Questions

Using dbms_pipe with C++ to perform daabase operation

I am getting two result: string and int in c++ code. That I want to store into database. The request which generates result is very frequent. So each time performing db operation to store the result is costly for me. So how this can be achived using dbms_sql? I dont have any experience and how... (1 Reply)
Discussion started by: karimkhan
1 Replies

7. Shell Programming and Scripting

How To Perform Mathematical Operation Within If in awk?

Hi All, I am using an awk script as below: awk -F'|' 'BEGIN{OFS="|";} { if ($1==$3 && $3==$7 && $7==$13 && $2==$6 && $6==$11 && $15-$14+1==$11) print $0"|""TRUE"; else print $0"|""FALSE"; }' tempfile.txt In above script, all conditions are being checked except the one which is... (4 Replies)
Discussion started by: angshuman
4 Replies

8. Shell Programming and Scripting

awk --> math-operation in a array

Hi main object is categorize the difference of data-values (TLUFT02B - TLUFT12B). herefor i read out data-files which are named acording to the timeformat yyyymmddhhmm. WR030B 266.48 Grad 0 WR050B 271.46 Grad 0 WR120B 268.11 Grad 0 WV030B 2.51 m/s ... (6 Replies)
Discussion started by: IMPe
6 Replies

9. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies

10. Shell Programming and Scripting

awk script to find data in three file and perform replace operation

Have three files. Any other approach with regards to file concatenation or splitting, etc is appreciated If column55(billngtype) of file1 contains YMNC or YPBC then pick the value of column13(documentnumber). Now find this documentnumber in column1(Billdoc) of file2 and grep the corresponding... (4 Replies)
Discussion started by: as7951
4 Replies
math::rationalfunctions(n)					       Math						math::rationalfunctions(n)

__________________________________________________________________________________________________________________________________________________

NAME
math::rationalfunctions - Polynomial functions SYNOPSIS
package require Tcl ?8.4? package require math::rationalfunctions ?1.0.1? ::math::rationalfunctions::rationalFunction num den ::math::rationalfunctions::ratioCmd num den ::math::rationalfunctions::evalRatio rational x ::math::rationalfunctions::addRatio ratio1 ratio2 ::math::rationalfunctions::subRatio ratio1 ratio2 ::math::rationalfunctions::multRatio ratio1 ratio2 ::math::rationalfunctions::divRatio ratio1 ratio2 ::math::rationalfunctions::derivPolyn ratio ::math::rationalfunctions::coeffsNumerator ratio ::math::rationalfunctions::coeffsDenominator ratio _________________________________________________________________ DESCRIPTION
This package deals with rational functions of one variable: o the basic arithmetic operations are extended to rational functions o computing the derivatives of these functions o evaluation through a general procedure or via specific procedures) PROCEDURES
The package defines the following public procedures: ::math::rationalfunctions::rationalFunction num den Return an (encoded) list that defines the rational function. A rational function 1 + x^3 f(x) = ------------ 1 + 2x + x^2 can be defined via: set f [::math::rationalfunctions::rationalFunction [list 1 0 0 1] [list 1 2 1]] list num Coefficients of the numerator of the rational function (in ascending order) list den Coefficients of the denominator of the rational function (in ascending order) ::math::rationalfunctions::ratioCmd num den Create a new procedure that evaluates the rational function. The name of the function is automatically generated. Useful if you need to evaluate the function many times, as the procedure consists of a single [expr] command. list num Coefficients of the numerator of the rational function (in ascending order) list den Coefficients of the denominator of the rational function (in ascending order) ::math::rationalfunctions::evalRatio rational x Evaluate the rational function at x. list rational The rational function's definition (as returned by the rationalFunction command). order) float x The coordinate at which to evaluate the function ::math::rationalfunctions::addRatio ratio1 ratio2 Return a new rational function which is the sum of the two others. list ratio1 The first rational function operand list ratio2 The second rational function operand ::math::rationalfunctions::subRatio ratio1 ratio2 Return a new rational function which is the difference of the two others. list ratio1 The first rational function operand list ratio2 The second rational function operand ::math::rationalfunctions::multRatio ratio1 ratio2 Return a new rational function which is the product of the two others. If one of the arguments is a scalar value, the other ratio- nal function is simply scaled. list ratio1 The first rational function operand or a scalar list ratio2 The second rational function operand or a scalar ::math::rationalfunctions::divRatio ratio1 ratio2 Divide the first rational function by the second rational function and return the result. The remainder is dropped list ratio1 The first rational function operand list ratio2 The second rational function operand ::math::rationalfunctions::derivPolyn ratio Differentiate the rational function and return the result. list ratio The rational function to be differentiated ::math::rationalfunctions::coeffsNumerator ratio Return the coefficients of the numerator of the rational function. list ratio The rational function to be examined ::math::rationalfunctions::coeffsDenominator ratio Return the coefficients of the denominator of the rational function. list ratio The rational function to be examined REMARKS ON THE IMPLEMENTATION
The implementation of the rational functions relies on the math::polynomials package. For further remarks see the documentation on that package. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: rationalfunctions of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhance- ments you may have for either package and/or documentation. KEYWORDS
math, rational functions CATEGORY
Mathematics COPYRIGHT
Copyright (c) 2005 Arjen Markus <arjenmarkus@users.sourceforge.net> math 1.0.1 math::rationalfunctions(n)
All times are GMT -4. The time now is 06:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy