Question: I am trying print data in rows and columns using bash script as follows.

```
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "$line"
done < "$1" 
{ 
   awk 'BEGIN { print "Points"}
      /Points/ { id = $1; }'
} 

```

My txt file looks like this:

```
Team    Played  Wins    Tied
england     4       3       2
america     9       5       3

```

The output on terminal should looks like this:

```
Team    Played  Wins    Tied  Points
england    4        3       2     16
america     9       5       3     26

```

Here is calculation a team won 1 match so awarded 4 points and for a tie, 2 points are awarded. But I don't know how to perform mathematical operations so unable to do.

Answer: 
You don't need a shell loop for this, at all:

```
awk '{$(NF+1) = NR==1 ? "Points" : $3*4 + $4*2; print}' OFS='\t' input.txt
Team    Played  Wins    Tied    Points
A       2       1       1       6
B       2       0       1       2

```
In plain bash, you could write:

```
while read -ra fields; do 
    if [[ ${fields[0]} == "Team" ]]; then 
        fields+=("Points")
    else 
        fields+=( $(( 4 * ${fields[2]} + 2 * ${fields[3]} )) )
    fi
    # changes to IFS variable done inside a subshell
    (IFS=$'\t'; echo "${fields[*]}")
done < "$1"

```