CSV file output data does not align with the right columns.
Account number (preferred / formatted),Customer reference,Posting date,Account currency,Transaction amount
750856653,233420,3/9/2019,USD,-2092.99
750856653,233417,3/9/2019,USD,-2856.15
750856653,233426,3/9/2019,USD,-2392.25
750856653,233414,3/9/2019,USD,-1733.22
750856653,233424,3/9/2019,USD,-1850.31
750856653,233403,3/9/2019,USD,-1850.32
750856653,233413,3/9/2019,USD,-1439.58
750856653,233431,3/9/2019,USD,-186.66
Script/code:
#!/bin/bash
input="/home/users/dcapps/bank/Monthsal.csv"
sed 's/,/:,/g' Monthsal.csv |
column -t -s: |
sed 's/ ,/,/g'
while IFS=',' read -r f1 f2 f3 f4 f5
do
echo "$f1 $f2 $f3 $f4 $f5 "
done < "$input"
The result should look like this:
Accountnumber Customerreference Postingdate Accountcurrency TransactionAmt
750856653 233420 3/9/2019 USD 2092.99
750856653 233417 3/9/2019 USD 2856.15
awk -F, '{ printf "%-15s %-19s %-14s %-18s %15s\n", $1, $2, $3, $4, $5 }' Monthsal.csv? (Putting the file name in a variable is pretty pointless, especially if you don't use the variable everywhere.)