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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.