#!/bin/sh
#] 
#] *********************
#] $ bash "$d_bin""symbols count in file.sh"  - generate symbol counts for a file
# www.BillHowell.ca  14Jan2019 initial
# based on "/media/bill/SWAPPER/Qnial/MY_NDFS/symbols count in file.sh"
# 


dater=$(date +"%y%m%d %kh%Mm")

#*******************************************************
#] setup_Lucas()  - 

	setup_Lucas()
{  
d_logger="/media/bill/SWAPPER/Qnial/MY_NDFS/"
d_source="/media/bill/SWAPPER/Lucas - Universal Force/"

if [[  "$HOWELL_computer" = "RaspPi"  ]]; then
   d_temper="/media/bill/RaspPi_ext4_32Gb/temp/"
else
   d_temper="/media/bill/ramdisk/"
fi

 finn="$d_source""Howell - Background math for Lucas Universal Force, Chapter 4.txt"
#finn="$d_source""Howell - math of Lucas Universal Force.txt"

p_logger="$d_logger""symbols log.txt"
echo  >>"$p_logger"  ""
}  


#] count_symbols()  - 

	count_symbols()
{  
p_symLst="$d_temper""symDiff bads $symSet.txt"
p_counts="$d_temper""symbols count in file f_symList.txt"
p_symCnt="$d_temper""symbols&count $symSet.txt"

rm  "$p_counts"

while read -r line; do
 	grep  -cF  "$line"  "$finn"  >>"$p_counts"
done < "$p_symLst" 

# final listing of symbol files and counts
echo  >>"$p_logger"  'symbols count in "d_temp/symDiff bads '$symSet'.txt" : '$dater
paste   "$p_counts"  "$p_symLst"  >"$p_symCnt"
rm "$p_counts"
}  


#] run_Lucas()  - 

	run_Lucas()
{
setup_Lucas

symSet="HFLN"
count_symbols

symSet="Lucas"
count_symbols
}



#*****************************************
# 14Jan2019  For this I had to remove trailing spaces in "authorsALL.txt" & "authorsChina sort unique.txt"


#] count_authorsChina()  - 

	count_authorsChina()
{  
d_source="/media/bill/SWAPPER/2019 IJCNN Budapest/"

if [[  "$HOWELL_computer" = "RaspPi"  ]]; then
   d_temper="/media/bill/RaspPi_ext4_32Gb/temp/"
else
   d_temper="/media/bill/ramdisk/"
fi

finn="$d_source""authorsALL.txt"

p_symLst="$d_source""authorsChina sort unique.txt"
p_counts="$d_temper""authorsChina counts in authorsALL.txt"
p_symCnt="$d_temper""authorsChina names&counts.txt"

rm  "$p_counts"


while read -r line; do
 	grep  -cFx  "$line"  "$finn"  >>"$p_counts"
done < "$p_symLst" 

# final listing of symbol files and counts
paste   "$p_counts"  "$p_symLst"  >"$p_symCnt"

total=0

# output total count
echo "Total authorChina count = "
paste -s -d+ "$p_counts" | bc

}  





#*******************************
# Do it

# run_Lucas
count_authorsChina



# 25Jul2018 old code
#p_basher="$d_temper""symbols count in file basher.sh"
#rm "$p_basher"

# grep  -cF  "Rocs(POIo)"  "/media/bill/SWAPPER/Lucas - Universal Force/Howell - Background math for Lucas Universal Force, Chapter 4.txt"  

#*************************************
# To run : 
# 1. set  $finn
# 2. run  $ bash "/media/bill/SWAPPER/bin/symbols count in file.sh" 




# enddoc
