I have a database where I wanted to generate a table of filecount using the combination of the rowKeyword and colKeyword.
Code:
#!/bin/bash
imgRootPath="."
for sCode in "S01" "S02" "S03" "S04" "S05" "S06" "S07" "S08"
do
for cCode in "C00" "C01" "C02" "C03" "C04" "C05" "C06"
do
#method 1 - working
echo $sCode $cCode
find "$imgRootPath" -type f -iname "*.bmp" -name "*_${sCode}_*" -name "*_${cCode}_*" | wc -l
#method 2
# echo $sCode $cCode $( find "$imgRootPath" -type f -iname "*.bmp" -name "*_${sCode}_*" -name "*_${cCode}_*" | wc -l )
#method 3
# echo $sCode $cCode $($( find "$imgRootPath" -type f -iname "*.bmp" -name "*_${sCode}_*" -name "*_${cCode}_*" | wc -l ))
#method 4
# count=$( find "$imgRootPath" -type f -iname "*.bmp" -name "*_$sCode_*" -name "*_$cCode_*" | wc -l )
# echo $sCode $cCode $count
#method 5
# count=$( find "$imgRootPath" -type f -iname "*.bmp" -name "*_${sCode}_*" -name "*_${cCode}_*" | wc -l )
# echo $sCode $cCode $count
#trial 6
# echo "$(find $imgRootPath -type f -iname "*.bmp" -name "*_${sCode}_*" -name "*_${cCode}_*" | wc -l)"
done
done
Output at the terminal looks like this:
PHP Code:
$ ./tabulateCnt.sh
S01 C00
189
S01 C01
711
S01 C02
160
S01 C03
49
S01 C04
0
:
:
:
As you can see in the output above, I get the filecount, however, I can not output it in the intended readable format like a table as seen below:
PHP Code:
C01 C02 C03 ...
S01 n11 n12 n13
S02 n21 n22 n23
S03 n31 n32 n33
:
:
OR at least as my failed attempts were trying to get
PHP Code:
S01 C01 n11
S01 C02 n12
S01 C03 n13
:
:
S02 C01 n21
S02 C02 n22
:
:
If I run any of the other cmd method (currently commented out) in the code above, nothing shows up on the screen in place of n** but the S0* and C0* get printed. The execution lag suggests that the "find" cmd is being executed in the bkgrnd. Can someone guide me to improve readability of the output ?