Numerical calculation by any programming language or Awk ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Numerical calculation by any programming language or Awk ??
# 8  
Old 07-22-2010
sorry

There is no logic.
Yes progressive numbers should be fine like 1_G_X...2_G_X etc...

One more thing please Can I get output like this ( a small change after removing 1st (2nd column) 78507634and last number (3rd column))
78534748

Code:
c1    78507663    78508442    1_G_X
c1    78508630    78519259    2_G_X
c1    78519438    78520148    3_G_X
c1    78520353    78524144    4_G_X
c1    78524319    78525627    5_G_X
c1    78525827    78534518    6_G_X

Thank you Rad
# 9  
Old 07-22-2010
Could you elaborate more? I don't understand this statement:

Quote:
a small change after removing 1st (2nd column) 78507634and last number (3rd column)
# 10  
Old 07-22-2010
here is the explanation

output1
Code:
c1    78507634    78507663    1_G_X
c1    78508442    78508630    2_G_X
c1    78519259    78519438    3_G_X
c1    78520148    78520353    4_G_X
c1    78524144    78524319    5_G_X
c1    78525627    78525827    6_G_X
c1    78534518    78534748    7_G_X

First remove (red) 1st value in 2nd col and last value in 3rd column. After that
take the values of 3rd column and preceding 2nd column
i.e. 78507663 78508442 and so on .......

output2
Code:
c1    78507663    78508442    1_G_X
c1    78508630    78519259    2_G_X
c1    78519438    78520148    3_G_X
c1    78520353    78524144    4_G_X
c1    78524319    78525627    5_G_X
c1    78525827    78534518    6_G_X

# 11  
Old 07-22-2010
Code:
awk '{
  n11 = split($11, t11, ",")
  n12 = split($12, t12, ",")
  for (i = 0; ++i < n11 - 1;) {
    s12 = $2 + t12[i]
    print $1, s12 + t11[i], $2 + t12[i + 1], i "_" $4
    }
  }' infile

This User Gave Thanks to radoulov For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

How is a new Web Development language written ?

I'm wondering how programmers develop new Web Development languages because I want to learn how everything begins from the start. Let's say I'm planning to write a new language for the Web. How do I do this? Is there anyone who knows about the way Web Development languages first appear ? I'm... (3 Replies)
Discussion started by: Anna Hussie
3 Replies

2. Programming

What Programming language should I start learning first?

I want to create a computer program that will translate from English to Spanish and vice versa. So someone could type in a word, phrase, or paragraph and translate from one language to another. What programming language would I use to write up the code and then implement this program? I want to... (8 Replies)
Discussion started by: Anna Hussie
8 Replies

3. Programming

How is a new Web Development language written ?

I'm wondering how programmers develop new Web Development languages because I want to learn how everything begins from the start. Let's say I'm planning to write a new language for the Web. How do I do this? Is there anyone who knows about the way Web Development languages first appear ? I'm asking... (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. UNIX for Dummies Questions & Answers

Is PERL a programming language?

I need a small and simple clarification... Can someone tell me whether PERL is a programming language or not. Also, can shell scripts also considered as programming language or not. Also, please tell me the exact difference between programming language and scripting. Please help.... (3 Replies)
Discussion started by: Anjan1
3 Replies

5. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

6. Programming

c programming language

Can someone enligten me on what below program does? I understand getchar and putchar.. but what is this program suppose to do? I try to put printf on it, but it shows nothing.. can someone explain to me what this program is suppose to do? It is reading something and assigning to c? so, if... (8 Replies)
Discussion started by: convenientstore
8 Replies

7. UNIX for Dummies Questions & Answers

Does the programming language matters?

I see you guys encouraged people studied and used C while they were working on UNIX. Does C++ or JAVA matter? And in the past threads, Neo, PxT, and other members recommanded lots good books. I think those people who asked for the references, such as Dominic, had experiences on sys admin or... (8 Replies)
Discussion started by: HOUSCOUS
8 Replies
Login or Register to Ask a Question