Issue
I have this script
#!/bin/bash
function labels2 () {
awk '
/[0-9]/{
print substr($3,length($3)-11), $3
}' $@ | /bin/sort -u | awk '{print "BUILD: " NR, $2}'
}
function labels () {
awk '
/[0-9]/{
BL[$3] = substr($3,length($3)-11)
}
END {
asort(BL)
for (i in BL) {
print i, BL[i]
}
}' $@
}
labels $@
exit 0
for a in $@
do
labels $@ | gawk '
/BUILD:/ {
BUILD[$2] = $3
BUILDCNT ++
next
}
/[0-9]/ {
DATEd[$3] = $1
TIMEd[$3] = $2
MODULESd[$3] = $4
CASESd[$3] = $5
FAILEDd[$3] = $6
COVERd[$3] = $7
LOCd[$3] = $8
}
END {
SUBSYSTEM=substr(FILENAME, 1, length(FILENAME)-7)
LABEL= "\"" toupper(SUBSYSTEM) "\""
print "{"
print "subsystem: " LABEL ","
print " date: {"
print " label: " LABEL ","
print " data: ["
for (i = 0 ; i <= BUILDCNT; i ++ ) {
B=BUILD[i]
if (DATEd[B]) { print " [" i ", \"" DATEd[B] "\"]," }
}
print " ]"
print " },"
}
' - $a
done
And this text input file cos.txt
2011-01-22 22:12 P16A22_110114072915 22 1312 75 13.55 1399
2011-01-22 22:12 P16A22_110114072915 22 1312 75 13.55 1399
now to my question, why is it printing out
1 110114072915
2 110114072915
instead of
{
subsystem: "COS",
date: {
label: "CAS",
data: [[1,"110114072915"],[2,110114072915]]
}
EDIT--------------------------------------------------------------------------------
I did as you guys said, and it partly worked. But now it comes on the form
1 110114072915
2 110114072965{
subsystem: "COS",
date: {
label: "COS",
data: [
[0, "3"],
]
},
And not on the form
{
subsystem: "COS",
date: {
label: "CAS",
data: [[1,"110114072915"],[2,110114072915]]
}
How can I change this? Also I want to do so that they come in order
in the array =)
Thanks yet again for your help =)
Solution
because of
labels $@
exit 0 <-- you told exit after the function "labels"... ;)
Answered By - clt60 Answer Checked By - Senaida (WPSolving Volunteer)