10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
In the below awk, I am trying to calculate percent for a given id. It is very close the problem is when the # being used in the calculation is zero. I am not sure how to code this condition into the awk as it happens frequently. The portion in italics was an attempt but that lead to an error. Thank... (13 Replies)
Discussion started by: cmccabe
13 Replies
2. Shell Programming and Scripting
The awk below is close but I can't seem to fix it to produce the desired output. Thank you :).
current awk with output
awk '{c1++; c2+=($2)}
END{for (e in c1) print e, c1, c2}' input
EFCAB5 2 50
USH2A 2 19
desired... (8 Replies)
Discussion started by: cmccabe
8 Replies
3. Shell Programming and Scripting
I am trying to run the awk below. My question is when I split the input, then run anotherawk to perform a calculation using that splitas the input there are no issues. When I try to combine them the output is not correct, is the split not working or did I do it wrong? Thank you :).
input
... (8 Replies)
Discussion started by: cmccabe
8 Replies
4. Shell Programming and Scripting
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
Discussion started by: sea
9 Replies
5. Shell Programming and Scripting
Hi guys,
could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?:
$ uname -a
Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64... (9 Replies)
Discussion started by: elixir_sinari
9 Replies
6. Shell Programming and Scripting
I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box.
The original code fragment he brought me was thus:
for (index=0; index < 1; index=index+.1)
... (4 Replies)
Discussion started by: mmyer2
4 Replies
7. Shell Programming and Scripting
Hi,
I have managed to round up numbers by using the following command:
echo "5.54" | awk '{printf "%.0f\n", $1}'
result
6
How can I round up all the numbers in a column in a file and print the lines with the new calculated totals?
Thanks, (3 Replies)
Discussion started by: keenboy100
3 Replies
8. Shell Programming and Scripting
Hi Friends,
I am trying to round following number.
0.07435000
echo "0.07435000"|awk '{printf "%s\n",$1*100}'|awk '{printf "%.2f\n",$1}'
It returns: 7.435
It should return: 7.44
Any suggestion please?
Thanks,
Prashant (2 Replies)
Discussion started by: ppat7046
2 Replies
9. UNIX for Dummies Questions & Answers
Hello
I am getting this very annoying issue in awk:
awk '{a=12825;b=a*1.25; print b}' test
16031.2
Thing is the multiplication result is wrong... Result should be 16031.25.
I think the issue only happens on bigger numbers.
What can I do to get passed this?
Thanks by advance (3 Replies)
Discussion started by: Indalecio
3 Replies
10. Shell Programming and Scripting
Hallo all,
I have a script which creates an output ... see below:
root@a7germ:/tmp/pax > cat 20061117.txt
523.047
521.273
521.034
517.367
516.553
517.793
513.114
513.940
I would like to use awk to calculate the (a)total sum of the numbers (b) The average of the numbers.
Please... (4 Replies)
Discussion started by: kekanap
4 Replies