05-06-2008
Namish,
Thansk for your reponse but I want the follwoing.
file.txt
111111111111111112000000000000
111111111111111112000000000000
111111111111111112000000000000
111111111111111112000000000000
output should be
444444444444444448000000000000
Sorry for any confusion.
Thanks
Ashu
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Friends
How to do sum on a column?
I have a file like:
FRED 500.01 TX
SMITH 50.10 NY
HARRY 5.00 CA
555.11
Sum on second column.
I am trying using nawk like
nawk 'BEGIN {FS="|"}; {printf $1"+"}'
Thanks a lot for your help
S :) (2 Replies)
Discussion started by: sbasetty
2 Replies
2. UNIX for Dummies Questions & Answers
I have a text file with two columns
the first column is an integer and the second column is date
how do i sum up the first column according to the date
example
123 jan1
232 jan1
473 jan2
467 jan2
356 jan3
376 jan3
my result should be
355 jan1
940 jan2
732 jan3
how do i... (2 Replies)
Discussion started by: ramky79
2 Replies
3. Shell Programming and Scripting
Hi All,
I have a file like -
num.txt
12, 34, 65, line1
34, 65, 89, line2
43, 65, 77, line3
I want to do two things -
1. Add first three columns of each line and print the line with largest value.
i.e. (12+34+65) for 1st line and so on.
2. Add middle column of each line i.e.... (3 Replies)
Discussion started by: asahlot
3 Replies
4. Shell Programming and Scripting
Hi
I need to sum of sub total amounts. Please any ideas
file1.txt
type: xx
xyz 200 300
xyz1 300 400
Sub total 500 700
type:yy
abc 200 300
abc1 100 100
Sub total ... (4 Replies)
Discussion started by: mohan705
4 Replies
5. Shell Programming and Scripting
Basically I have to process a text file which has been sorted this way:
John 12
John 13
John 10
John 900
Peter 20
Peter 30
Peter 32
The first column is a name, and the second an arbitrary value, both delimited by a space. How can I sum them up such that it would become:
John 935... (2 Replies)
Discussion started by: Dwee
2 Replies
6. Shell Programming and Scripting
I have two files
hhhh 3674.00
a 75 1535 183 2134 291 2452 442 2738 704 3048
a 1007 3549 1282 4413 1494 5001 1631 5217 1954 5610
a 2540 5832 3248 6080 3629 6264 4851 6600 7004 6985
... (4 Replies)
Discussion started by: Indra2011
4 Replies
7. Shell Programming and Scripting
My file is something like this :
03.097
03.094
03.093
03.095
03.091
04.089
06.093
07.225
08.196
06.097
06.094
05.096
04.086
I'd like to sum it from a given line to another one , e.g.: from line 10 until line 20
What s the awk way solving this ? (1 Reply)
Discussion started by: firelink
1 Replies
8. Shell Programming and Scripting
I'm trying to sum a text file using AWK. Here is an example of the file:
600|3H68| 46
600|3H69| 46
600|3H6F| 290
600|3H6G| 24
600|3HDY| 1
600|3HDY| 3
600|3HE0| 1
600|3HE0| 3
I would like to sum the third field if the first... (7 Replies)
Discussion started by: Drenhead
7 Replies
9. Shell Programming and Scripting
I was playing around to see how stuff works, and was trying to sum all fields in a file.
cat file
1 2 3 4
5 6 7 8
9 10 11 12
I made this script:
awk 'BEGIN {OFS=RS}{$1=$1}{s+=$0} END {print "sum="s}' file
This gives 15, why not 78?
I test it like this
awk 'BEGIN... (5 Replies)
Discussion started by: Jotne
5 Replies
10. Shell Programming and Scripting
hi All,
i have a file in which only one column is there.,
test.txt
======
-900.01
-900.02
-900.03
-900.04
-900.05
-900.06
-900.07
-900.08
-900.09
900.01
900.02
900.03
900.04
900.05 (4 Replies)
Discussion started by: mechvijays
4 Replies
LEARN ABOUT OPENSOLARIS
txt2pdbdoc
txt2pdbdoc(1) General Commands Manual txt2pdbdoc(1)
NAME
txt2pdbdoc - Text to Doc file converter for Palm Pilots
SYNOPSIS
txt2pdbdoc [-b] [-c] [-v] document-name file.txt file.pdb
txt2pdbdoc -d [-D] [-v] file.pdb [ file.txt ]
txt2pdbdoc -V
DESCRIPTION
txt2pdbdoc converts a plain text file to a Doc(4) file in PDB (Pilot Database) format used by all models of the Palm Pilot. (It can also
convert a Doc file to plain text.) Resultant PDB files can be downloaded directly to a Pilot during a HotSync.
The document-name is used in the Document List view of a Doc reader application on the Pilot.
OPTIONS
-b Ordinarily, characters with an ASCII code less than 9 are removed and both carriage-returns and form-feeds are converted to newlines.
This option suppresses that behavior.
-c Ordinarily, text is compressed. This option suppresses compression.
-d Decode the given Doc file to text either to a file or to standard output if no file is specified.
-D Do not check the file type/creator of the file to decode. This option should be specified only if you know for sure that the file is
in fact some sort of Doc file. Attempting to decode non-Doc files will result in undefined behavior and quite possibly crash.
-v Verbose mode. For encoding, print progress and compression statistics per 4K of text to standard error as well as overall statistics
when completed; for decoding, print progress in a ``countdown'' style.
-V Print the version number of txt2pdbdoc to standard output and exit.
EXAMPLE
To convert a text file to Doc file:
txt2pdbdoc 'Through the Looking Glass' alice.txt alice.pdb
EXIT STATUS
Exits with one of the values given below:
0 Success.
1 Error in command-line options or use.
2 Unable to open source file.
3 Unable to open destination file.
4 Unable to read file.
5 Unable to write file.
6 File is not a Doc file.
7 Doc file uses unknown compression type.
CAVEATS
1. Document names are limited to 31 characters in PDB format. Longer names are truncated but have the 29-31st characters replaced by
``...'' to indicate truncation.
2. The command isn't called ``txt2doc'' to avoid confusion about possibly having anything to do with Microsoft Word documents that use the
.doc extension.
SEE ALSO
html2pdbtxt(1), pdbtxt2html(1), doc(4), pdb(4)
AUTHOR
Paul J. Lucas <pauljlucas@mac.com>
txt2pdbdoc January 21, 2005 txt2pdbdoc(1)