Search Results

Search: Posts Made By: bjoern456
5,735
Posted By RudiC
(linux) man ls: If that is not absolutely...
(linux) man ls:
If that is not absolutely essential, tryfor i in *
do echo item: $i
if [ -s line${i}_Ux.xy ]
then awk '{a+=$2; n++;} END {print a/n}' $i
else...
10,816
Posted By alister
The for-in-loop should not be used. The OP wants...
The for-in-loop should not be used. The OP wants to preserve the order of the list, buti in a is not guaranteed to preserve order.

awk '{sum+=$2; a[NR]=$1} END{for (i=1; i<=NR; i++) {print...
5,735
Posted By vbe
That said looking at your script now, do you mind...
That said looking at your script now, do you mind explaining what $( ls -v ) is supposed to give and what OS we are dealing with ( and the shell used perhaps?) because -v is not implemented on AIX or...
5,735
Posted By vbe
you are missing a fi, thats all, just before the...
you are missing a fi, thats all, just before the last line...


for i in $( ls -v )
do
echo item: $i
if [ ! -s line$i_Ux.xy ]; then
echo -e "0" >> list
else
cat...
10,816
Posted By krishmaths
awk '{sum+=$2;a[++i]=$1} END{for (i in a) {print...
awk '{sum+=$2;a[++i]=$1} END{for (i in a) {print a[i]"/"sum}}' infile
10,816
Posted By pamu
$ awk 'NR==FNR{a+=$2;next}{print $1"/"a}' file...
$ awk 'NR==FNR{a+=$2;next}{print $1"/"a}' file file
1/5
2/5
3/5
4/5
1,453
Posted By rdrtx1
formula in example does not show average...
formula in example does not show average calculation, but try:
awk 'NR==1 {a=$1} {b+=$2; c=$1} END {print (b/NR) * (c - a)}' input
7,460
Posted By Yoda
This awk code might help: awk ' { ...
This awk code might help:
awk '
{
if ( $1 in L )
{
L[$1] = L[$1] > $2 ? $2 : L[$1]
H[$1] = H[$1] < $2 ?...
7,460
Posted By Yoda
Here is another awk approach: awk ' {...
Here is another awk approach:
awk '
{
if ( $1 in L )
{
L[$1] = L[$1] > $2 ? $2 : L[$1]
H[$1] = H[$1] < $2...
7,460
Posted By RudiC
Try:awk ' {if (!L[$1] && $2 < L[$1])...
Try:awk ' {if (!L[$1] && $2 < L[$1]) L[$1]=$2
if (!H[$1] && $2 > H[$1]) H[$1]=$2}
END {for (x in L) print x, L[x], H[x]}
' file
1 -0.1 0.1
2 -0.2...
7,460
Posted By DGPickett
Just create two variables and load them with the...
Just create two variables and load them with the first column value (min and max so far). On lines 2-$ check to see if you have a new min, and if not, do you have a new max (can't be both!)?
1,852
Posted By bartus11
Try:awk '{s[$1]+=$2;n[$1]++}END{for (i in s)...
Try:awk '{s[$1]+=$2;n[$1]++}END{for (i in s) print i,s[i]/n[i]}' list.txt
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 05:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy