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)
Hi,
I want to add 3 new fields in the existing file.Please find the example below.
input:
UID: ABCD
UNAME: XYZ
Desired Output
Tmiestamp: 20101208
UID: ABCD
UNAME: XYZ
DEPTNO:40
ModifyTImestamp:20101209
If you see the above i have added the 3 columns manually in the output section... (2 Replies)
Hi I need to do the following substitution
I have to look for line starting with ABC and add 4 ":" before the first occurence of "+"in that line
Input
ABC:12:Lambert:C278472:1357:0:0:0:0:2:N::::N:9045123:NAP::+DEF
output
ABC:12:Lambert:C278472:1357.00:0.00:0:0:0:2:N::::N:9045123:NAP::::::+DEF... (5 Replies)
How would I print out the total amount through awk? I tried using
print "Total Amount: " $4+$4;
Would I have to do a for loop to get through everything? (2 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)
by the script, two files Q1 and Q2 will be generated on the system. Q1 will contain an integer number and Q2 also contain an integer number. i would like to add those numbers and put into new file.
excerpt from my script
22 subcount=`echo $dir/Q$qid.txt` + `echo $dir/Q$qid.txt`
23 echo... (1 Reply)
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)
Hello all
I have a statement :
ARRAY_MOUNT_POINT_NAME=`df -h | awk '{print $6}'| head -`expr $i+2` |tail -1`
when the value of i=0 , I want the head argument to be at -2 . Using the expr statement isnt working.
Help ! (5 Replies)
Discussion started by: Junaid Subhani
5 Replies
LEARN ABOUT SUNOS
sum
sum(1) User Commands sum(1)NAME
sum - print checksum and block count for a file
SYNOPSIS
sum [-r] [file...]
DESCRIPTION
The sum utility calculates and prints a 16-bit checksum for the named file and the number of 512-byte blocks in the file. It is typically
used to look for bad spots, or to validate a file communicated over some transmission line.
OPTIONS
The following options are supported:
-r Use an alternate (machine-dependent) algorithm in computing the checksum.
OPERANDS
The following operands are supported:
file A path name of a file. If no files are named, the standard input is used.
USAGE
See largefile(5) for the description of the behavior of sum when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of sum: LC_CTYPE, LC_MESSAGES, and
NLSPATH.
EXIT STATUS
The following exit values are returned.
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Availability |SUNWesu |
|CSI |enabled |
+-----------------------------+-----------------------------+
SEE ALSO cksum(1), sum(1B), wc(1), attributes(5), environ(5), largefile(5)DIAGNOSTICS
"Read error" is indistinguishable from end of file on most devices; check the block count.
NOTES
Portable applications should use cksum(1).
sum and usr/ucb/sum (see sum(1B)) return different checksums.
SunOS 5.10 7 Nov 1995 sum(1)