0

Hi everyone,

Here is my problem:

I have different data files each with several columns and row of data.
datafile1 , datafile2, ...

Now I need to do some simple math procedure of this data files, Lets say I need to add the 3rd column of datafile1 to the 2nd column of the datafile2.

I was thinking to write a shell script that does so, but I don't have a clue where to start. Any suggestion is very appreciated.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Fest3er
0

This might be along the lines of what you were looking for.

#! /bin/bash

while : do
  read a <&4 || break
  read b <&5 || break
  set a
  col3=$3
  set b
  col2=$2
  echo $(($col3+$col2))
done 4<datafile1 5<datafile2

However, bash can be awkward handling multiple files. Perl or gawk would be better.

Edited by Fest3er: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.