echo -n "Secure Client licenses (CPVP-VSC-5-NGX+xx): "; cplic print |grep never | grep -v -E "CPVP-VSC-[0-9]+-NGX " |grep -o -E "CPVP-VSC-5-NGX+........" |sed 's/CPVP-VSC-5-NGX+//g' |awk '{ total = total + $1 } END { print total }'; echo -n "Secure Client licenses (CPVP-VSC-xx-NGX): "; cplic print |grep never | grep -o -E "CPVP-VSC-[0-9]+-NGX " | sed 's/CPVP-VSC-//g' | sed 's/-NGX//g' | awk '{ total1 = total1 + $1 } END { print total1 }' ; echo "User Center Key:"; cplic print |grep never | grep "CPVP-VSC-" | grep -o -E "SWB CK-............"| awk '{print $2}' |sed 's/CK-//g'
I modified your's slight so it can deal with arbitrary license values:
cat test.txt |grep never | grep -o -E "CPVP-VSC-[0-9]+-NGX " | sed 's/CPVP-VSC-//g' | sed 's/-NGX//g' | awk '{ total1 = total1 + $1 } END { print total1 }'
175
the [0-9]+ matches one or more numbers, plus the space after NGX means that it won't accidentally count CPVP-VSC-5-NGX+yy ones.
I updated the cplic test file to the below to validate
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-5-NGX+100 CPEP-SUBSCR CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-5-NGX+30 CPEP-SUBSCR CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-25-NGX CPEP-PERP CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-25-NGX CPEP-PERP CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-5-NGX+10 CPEP-PERP CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-50-NGX CPEP-PERP CPSB-SWB CK-1ABCD123A123
1.2.3.4 never CPVP-VPS-1-NGX CPVP-VSC-75-NGX CPEP-PERP CPSB-SWB CK-1ABCD123A123
[Expert@FWMGMT01:0]# cat licensetest.txt |grep never | grep -o -E "CPVP-VSC-[0-9]+-NGX " | sed 's/CPVP-VSC-//g' | sed 's/-NGX//g' | awk '{ total1 = total1 + $1 } END { print total1 }'
175
Now we just need to get it shoved back into the one liner... 🙂
edit:
@HeikoAnkenbrand
I modified your full one liner above to deal with brbitrary valuse for the "other" style.
echo -n "Secure Client licenses (CPVP-VSC-5-NGX+xx): "; cplic print |grep never | grep -v -E "CPVP-VSC-[0-9]+-NGX " |grep -o -E "CPVP-VSC-5-NGX+........" |sed 's/CPVP-VSC-5-NGX+//g' |awk '{ total = total + $1 } END { print total }'; echo -n "Secure Client licenses (CPVP-VSC-xx-NGX): "; cplic print |grep never | grep -o -E "CPVP-VSC-[0-9]+-NGX " | sed 's/CPVP-VSC-//g' | sed 's/-NGX//g' | awk '{ total1 = total1 + $1 } END { print total1 }' ; echo "User Center Key:"; cplic print |grep never | grep "CPVP-VSC-" | grep -o -E "SWB CK-............"| awk '{print $2}' |sed 's/CK-//g'
The output when I pass it across the license file as above is:
Secure Client licenses (CPVP-VSC-5-NGX): 140
Secure Client licenses (CPVP-VSC-25-NGX): 175
User Center Key:
1ABCD123A123
1ABCD123A123
1ABCD123A123
1ABCD123A123
1ABCD123A123
1ABCD123A123
1ABCD123A123
Which looks absolutely perfect to me.
Thanks so much for this, as I spent most of Monday this week counting bloody licenses in cplic prints.