I am new to bash scripting I have the following CSV
Input
ID Location Way Day DayTime NightTime StandNo
1 abc Up mon 6.00 18.00 6
Expected Output
ID Location Way Day DayTime NightTime StandNo
1 ABC UP Mon 6.00 18.00 6
I need to check Location and Way and convert them to UpperCase - ABC, UP Day needs to be mon - Mon I need to do this for entire CSV. I need to correct the value and write all the fields on to CSV or edit the current cell and save CSV My script is as follows
file = "Myfile.csv"
while IFS="," read line
do
output=`echo $line | cut -d "," -f2`
echo $output
for i in $output
do
if [ -z $(echo $I | sed -e "s/[a-z]//g") ]
then
echo $I | tr "[:lower:]" "[:upper:]" >> ".tempfile.CSV"
fi
done
done <$file
`1. Currently this writes only the corrected value and not entire line along with corrected value. [Unsure how I can loop thru cell values in every row correct the ones which needs correction and then copy the entire row]
Any help would be useful.
#!/bin/bash. Good luck.