I have a file storing the course content taken by a student:
Sample outputA:
------------------------------------------------------------------------------------------------------------------------
                Year            Semester                Code             Credits                 Tag         letterGrade
------------------------------------------------------------------------------------------------------------------------
                2019              Autumn              CS 753                   6 Department elective                  AB
                2019              Autumn              CS 490                   6         Honors core                  CC
                2019              Autumn              CS 492                   6         Honors core                  FR
                2019              Autumn              CS 747                   6 Department elective                  FF
                2019              Autumn              ES 200                   3      Basic Sciences                  BC
                2019              Autumn              ET 601                   6  Institute Elective                  BB
I want to echo them to a terminal using a bash script with each line colored according to the course tag. The information on how to color is given in another file:
Source CSV to process ./resources/creditsRequirements.csv:
tag,credits,color_FONT,color_BACKGROUND,
Basic Sciences,62,CYAN,BLACK,
Engineering Science,29,BLACK,GREEN,
HSS Elective,12,GREEN,BLACK,
Institute Elective,12,BLACK,WHITE,
Core course,117,BLACK,CYAN,
Department elective,36,YELLOW,BLACK,
Honors core,24,WHITE,BLACK,
Minor,30,MAGENTA,WHITE,
Additional Learning,0,RED,WHITE,
I can't use any command other than sed or awk.
I want to do something like this (outputA and ./resources/creditRequirements.csv are command line arguments):
awk -F"," 'NR!=1{system("sed -e 's/^.\{1,\}($1).\{1,\}$/(code for color)&(code for reset)/g' "$1)}' $2
But this is happening (I used a shorter sed command just to test it):
./viewWithColor.sh outputA ./resources/creditsRequirements.csv
awk: cmd. line:1: NR!=1{system("sed -e /[0-9]/ awk: cmd. line:1: ^ unterminated string awk: cmd. line:1: NR!=1{system("sed -e /[0-9]/ awk: cmd. line:1: ^ syntax error
 
     
     
    