How can it serve the purpose with 'awk' program?
Hello, guys
I met the troubles in calculating the sum of the products referring to the input file as follow, 0.900 0.100 0.900 0.100 0.800 0.200 1.000 10.238558 6.967603 10.238558 6.967603 7.860238 10.098804 12.669123 from which the products are calculated by multiplying the number in row 1 with that in row 8, row 2 with that in row 9, others done by analog. thanks. |
Welcome to LinuxQuestions! :)
What is the purpose of this script? Homework? How many lines it contains? If it is a very large file (I mean yours posted above is just an example) I'd start by splitting the file using split, so that it is far more easy to manage couples of values. |
Give us an example of what you have tried---and: Why you want to use Awk?
Since BASH does not support non-integer math, you will need a utility like "bc"---or maybe just use Python. |
Quote:
|
Quote:
|
Quote:
|
Quote:
In fact, I'm not familiar with linux at all, it's just an assignment by my boss, this is the simple case. The number of lines in real case is variable, but here, I just appreciate an awk program example from you so I may try the similar way to do something more. As you mentioned, splitting into two inputfiles might be more convenient. I did consider that but got no solution due to poor command of it. If you give me an example referring to two inputfiles it will be helpful. Thanks. |
Quote:
|
Quote:
Our rules and policies about homework can logically also apply to helping you with your job assignments-----If you are expected to know how to do certain things, we will be doing you a disservice by doing them for you. If you are going to get more assignments like this, then we need to help you learn ALL of the relevant tools. SO....please tell us more about what kind of work you are doing...and more about the context of this particular question. |
Quote:
If any ambiguous expression occured, i apologize. Thanks again |
A couple of good awk pages: GNU awk manual and Grymoire.
The ethos on LQ is to help people who have tried and got stuck or who have specific questions. There are a couple of reasons for that. Firstly questioners learn more if they try for themselves and secondly we are more inclined to spend time answering questions if the questioner has spent some time themselves. |
Quote:
I did not ask you to describe the entire assignment---just give us the context. In the interests of trying to help you for the long run, I really want to know if you are in a situation where you are expected to know how to do this. If you do not want to provide any information, that's OK---but it certainly reduces your chances of getting any help here. |
All times are GMT -5. The time now is 02:51 AM. |