By radudownload
I sometimes need to do some simple arithmetics, like adding a number to a certain column of a file. So I wrote a small function in the .bashrc file, which looks like this
shifter()
{
COL=$1
VAL=$2
FILE=$3
cp $FILE $FILE.shifted
awk 'NF==4 {$(( $COL )) = $(( $COL )) + $VAL}' $FILE.shifted
}
which should add the number stored in VAL, to the column COL from the FILE file.
Please give me a hint how should I make this work. Thank you! (I’m just a newbie in shell programing)