Adding from a file


 
Thread Tools Search this Thread
Operating Systems Solaris Adding from a file
# 1  
Old 03-22-2005
Adding from a file

Smilie The file data.txt holds the following data
125
587
589

In a ksh script, I need a way to output the sum of all the records in the file. Any ideas?

Thanks
# 2  
Old 03-22-2005
echo `sed -e 's/$/+/' data.txt` 0 | bc
# 3  
Old 03-22-2005
man sum

gP
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

2. Shell Programming and Scripting

Adding single value from one file into column of second file

I have two files with the following content: file1.txt looks like this (it always only have one single row): ABC file.txt looks like this (may have tons of rows): 123 456 789 I want to make a bash script that gives the following output: ABC 123 ABC 456 ABC 789 So it takes the... (9 Replies)
Discussion started by: Zooma
9 Replies

3. Shell Programming and Scripting

Adding content of two file in a single file column wise

Hi, I am trying to get the file in particular pattern using shell script. I have to add one column to some other file. For example consider two file as below. File1: name1 name2 name3 File2: Add1 age1 Add2 age2 Add3 age3 I want this two file in a single file format something like... (3 Replies)
Discussion started by: diehard
3 Replies

4. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

5. Homework & Coursework Questions

adding rows of a file and display in another file

How to add these all ( 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25) in the script and How to calculate the GPA?? :wall: For example a course record file can be like this: COURSE NAME: Operating Systems CREDITS: 4 123456 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25 243567 0 1 1 0 1 1 0 1 0 0 0 7 9 12 15 17 15... (1 Reply)
Discussion started by: poonam29
1 Replies

6. Shell Programming and Scripting

adding rows of a file and display in another file

How to add these all ( 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25) in the script and How to calculate the GPA?? :wall: For example a course record file can be like this: COURSE NAME: Operating Systems CREDITS: 4 123456 1 1 0 1 1 0 1 0 0 0 1 5 8 0 12 10 25 243567 0 1 1 0 1 1 0 1 0 0 0 7 9 12 15 17 15... (1 Reply)
Discussion started by: poonam29
1 Replies

7. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

8. UNIX for Dummies Questions & Answers

adding text from a file to the top of the file

Hi all, I need a include a text from the file and include it in the top of the other file.. i.e file 1 contains AAA BBB CCC DDD EEE file2 contains 333 44 23 452 54235 232341 4321414 Now i need to insert the text from file1 to file2 at the top of the file2. (13 Replies)
Discussion started by: sivakumar.rj
13 Replies

9. Shell Programming and Scripting

Adding the values of two file

I have two files as Count1 and Count2. The count contains only one values as 10 and count2 contains only one values as 20. Now I want third file Count3 as count1+Count2. That is it should contain sum of two file(10+20=30) (3 Replies)
Discussion started by: Shell_Learner
3 Replies

10. Shell Programming and Scripting

Need Help for Adding Three new columns in existing file from fatching data from file

not required this time (36 Replies)
Discussion started by: Sandeep_Malik
36 Replies
Login or Register to Ask a Question