You didn't say how many lines (records) there were, but this should work for any number of lines:
If you need to skip summing the first field (which you apparently do) then start "i=2" (both places), and then add "printf "%s|",a[1]" before the final "for" loop.
I add up the number of args that are not blank. It works, but the printout is a string that just keep concatenating on +1. So Ex. it goes through input of: bob toto " " tom ...I get 0+1+1+1, when all I want is 3. Any help is appreciated.
count=0
for name in $*
do
if ; then
... (3 Replies)
i have a script called date_add.sh written in k_shell
My shell script requirement is that it accepts a date from the user in the format YYYY-MM-DD and then it shows all the 15 days later day availaible in the current year
if date accepted from user is 2008-10-13,then the o/p sholud be... (5 Replies)
Hi all,
I am getting following output by using commands like sort, uniq and awk to the standard output.
110 d
40 a
59 c
9 b
3 e
Now at the end I would like to add all the numbers in column 1 and display the count of all numbers i.e. (110 + 40 + 59 + 9 + 3).
Also the output may... (3 Replies)
Hi all,
I am very new to shell programming and trying to learn out the basics.
I tried this:
$ echo `expr 20 + 30`
and it worked. But when i tried this,it does not work.
$ a=20
$ b=30
$ echo `expr a + b`
The error is:
expr: non-numeric argument
I cant understand why its... (3 Replies)
i need shell script to add to numbers
#!/usr/bin/sh
a=1310601600 ------> epcho time of Thu, 14 Jul 2011 00:00:00 UTC
b=864000 -------> 10 days in sec
c=`expr $a+$b`
echo $c----1311465600> this output i will use this value to delete the data from MySQL db
next i need to set... (3 Replies)
a=10.00
pattern=-11.00
b=`echo "$a $pattern" | awk ' printf("%d\n", $1 + $2)'`
echo $b
not working, also trined bc ,dc but thats not on my m/c.
also expr not supporting.
any clue? (6 Replies)
whats wrong with this addition?
Whats the maximum number of digits can be handled?
pandeeswaran@ubuntu:~/Downloads$ const=201234454654768979799999
pandeeswaran@ubuntu:~/Downloads$ let new+=const
pandeeswaran@ubuntu:~/Downloads$ echo $new
-2152890657037557890
pandeeswaran@ubuntu:~/Downloads$ (4 Replies)
Hi
I have a file whose contents are as follows:
sorce1 LEN assumption 695 3570 0.770047 - . ID=f000001.1;source_id=A.off_LEN_10008424;
sorce1 LEN descriptive 3334 3570 . - 0 Parent=f000001.1;
sorce1 LEN ... (8 Replies)