I have two files.
First one is csv while other one is plain text file.
I want to print all the lines of file2 which contains column 1 of first file with font color column2 and background color column3.
for example:
f1 contains
Basic Engineering,BLACK,WHITE
Science,RED,BLUE
f2 contains with field width of 20 each:
foo abc Science AA
bar cde Basic Engineering AP
baz efgh Science AB
expected output:
foo abc Science AA (Red font, Blue background)
bar cde Basic Engineering AP (Black font, White background)
baz efgh Science AB (Red font, Blue background)
I have already defined color in a seperate file defineColors.sh as:
BLACK_FONT=`tput setaf 0`
RED_FONT=`tput setaf 1`
WHITE_BACKGROUND=`tput setab 7`
BLUE_BACKGROUND=`tput setab 4`
RESET_ALL=`tput sgr0`
My try :
awk -F, '{sed "/$1/p" f2 | sed -e 's/^\(.*\)$/'"$2_FONT"''"$3_BACKGROUND"'\1/' }' f1
awk -F'|' 'NR==FNR{c[$1]++;next};c[$1] > 0' file1 file2 > output.txtjust work around that