![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 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 |
| Simulate SVN diff using plain diff | ackbarr | Shell Programming and Scripting | 3 | 02-07-2009 01:01 PM |
| How to calculate with awk | whatisthis | Shell Programming and Scripting | 4 | 11-09-2005 12:39 PM |
| How to calculate a sum of certain records? | sickboy | Shell Programming and Scripting | 10 | 06-10-2005 11:43 AM |
| diff 2 files; output diff's to 3rd file | blt123 | Shell Programming and Scripting | 2 | 05-28-2002 11:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
calculate diff in csv
I wrote a func to calculcate integers difference in csv.
getSegLatency() { latencies=0$1 E2E=0`echo $2 | sed 's/\.000000//g'` integer segLatency=0 set -A arr `echo $latencies | sed 's/\.000000//g' | sed 's/,/ /g'` res=${arr[0]} integer i=1 while ((i < ${#arr[*]})); do ((segLatency=${arr[$i]} - ${arr[$i - 1]})); res="$res,$segLatency" (( i = i + 1)); done ((segLatency=$E2E - ${arr[$i - 1]})); res="$res,$segLatency" echo $res } in which the number of elements in $1 may vary e.g. when i call like: getSegLatency 1.000000,4.000000,6.000000,7.000000 11.000000 i'll get: 3,2,1,4 It works well but the performance is slow. Is there any way to polish the script to run faster? |
| Sponsored Links | ||
|
|