File: bompp.sh

package info (click to toggle)
geda-gnetlist 20050313-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,092 kB
  • ctags: 702
  • sloc: lisp: 5,519; ansic: 3,809; sh: 3,647; makefile: 291
file content (52 lines) | stat: -rwxr-xr-x 1,175 bytes parent folder | download | duplicates (4)
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
51
52
#!/bin/sh
# ha ha

if [ -z $1 ] ; then
    echo "usage $0 geda-bom  # output on stdout"
    exit -1
fi    
cat $1 | awk '{print toupper($2)" "toupper($3)" "toupper($4)" "toupper($1)}'\
| sort +0 | awk '\
BEGIN {\
f1="";f2="";f3="";\
format1="%3d %-19s %-10s %-10s ";\
format4="%-46s";\
format2="%s, ";\
format3="%s\n";\
format5="%s,\n";\
urefsperline=5;\
printf(format1 format3, 0, "Device", "Value", "Footprint", "Urefs");\
}\
/^DEVICE/{}\
!/^DEVICE/{\
    if($1==f1 && $2==f2 && $3==f3) {\
        array[ct++]=$4;\
    } else {\
        if(f1!="" && f2!="" && f3!="") { \
            printf(format1, ct, f1, f2, f3);\
	    for(i=0; i<ct-1; i++) {\
	        if((i+1)%urefsperline) {\
		    printf(format2, array[i]);\
		} else {\
		    printf(format5 format4, array[i], "");\
		}\
	    }\
	    printf(format3, array[i]);\
        }\
        f1=$1;f2=$2;f3=$3;ct=0;array[ct++]=$4;\
    }\
}\
END{\
    if(f1!="" && f2!="" && f3!="") { \
        printf(format1, ct, f1, f2, f3);\
	for(i=0; i<ct-1; i++) {\
	    if((i+1)%urefsperline) {\
	    printf(format2, array[i]);\
	} else {\
	    printf(format5 format4, array[i], "");\
	}\
    }\
    printf(format3, array[i]);\
}\
}'