I have a text file with this information:
Game Copies_Sold(M) Release_date Genre
God_of_War 19 20/04/2018 Action-Adventure
Uncharted_4 16 10/05/2016 Action-adventure
Spider-Man 13 07/09/2018 Action-adventure
The_Witcher_3 10 18/05/2015 Action_role-playing
and I need to sum the numbers of the second column, so I wrote this script:
#!/bin/bash
file=$1
s=0
tail -n +2 $file |cut -f 2 |
{ while read line
do
s=$(( $s+$line ))
done <$file }
echo $s
but obviously I do something wrong. What's to be done here? Thank you!