File: compmatrix.sh

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (50 lines) | stat: -rwxr-xr-x 2,162 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
#
# Shellscript to investigate use of comps in the example instrs.
#   Usage: ./compmatrix.sh
#   Outputs:
#     comps_no_examples.txt
#       (list of comps with 0 examples, disregarding sasmodels, obsolete)
#     sources/sources_examples.txt
#       (list of source comps with their examples)
#     optics/optics_examples.txt
#       (list of optics comps with their examples)
#     etc... 

COMPDIR=$PWD
echo --------------------------------------- > ${COMPDIR}/comps_no_examples.txt
echo Comps with no examples \(disregarding   >> ${COMPDIR}/comps_no_examples.txt
echo  sasmodels and obsolete categories\)    >> ${COMPDIR}/comps_no_examples.txt
echo --------------------------------------- >> ${COMPDIR}/comps_no_examples.txt
for category in $(find . -name \*.comp | cut -d / -f2 | sort | uniq | grep -v parked)
do
    echo Missing examples from ${category} >> ${COMPDIR}/comps_no_examples.txt
    cd ${COMPDIR}/${category}
    echo --------------------------------------- > ${category}_examples.txt
    echo List of $category comps and the         >> ${category}_examples.txt
    echo example instruments that include them   >> ${category}_examples.txt
    echo --------------------------------------- >> ${category}_examples.txt
    for comp in $(ls *.comp | sed s/.comp//g)
    do
	examples=$(grep -H ${comp} ${COMPDIR}/examples/*/*/*instr | cut -f1 -d: | sort | uniq | xargs -n1 basename)
	num_examples=$(echo $examples | wc -w)
	echo $comp is used in $num_examples example\(s\): >> ${category}_examples.txt
	echo $examples | xargs -n1 echo - >> ${category}_examples.txt
	echo --------------------------------------- >> ${category}_examples.txt
	if [ $num_examples -lt 1 ]
	then
	    if [ $category != "sasmodels" ]
	    then
		if [ $category != "obsolete" ]
		then
		    echo - $comp in $category is not in any example >> ${COMPDIR}/comps_no_examples.txt
		fi
	    fi
	fi
    done
    if [ $category == "sasmodels" ] || [ $category == "obsolete" ]
    then
	echo ... Not reporting comps in $category >> ${COMPDIR}/comps_no_examples.txt
    fi
    echo --------------------------------------- >> ${COMPDIR}/comps_no_examples.txt
done