Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Tested on: Oracle Linux
Unified · Split
| @@ -94,8 +94,12 @@ awk '/version/{ · 93 unmodified lines | ||
| 94 | 94 | substr($0,RSTART,RLENGTH)) |
| 95 | 95 | }' |
| 96 | 96 | |
| 97 | −pppd --version 2>&1| grep version | awk \ | |
| 98 | −'NR==1{print "PPP ", $3}' | |
| 97 | +pppd --version 2>&1 | | |
| 98 | +awk '/version/{ | |
| 99 | + match($0, /[0-9]+([.]?[0-9]+)+/) | |
| 100 | + printf("PPP\t\t\t%s\n", | |
| 101 | + substr($0,RSTART,RLENGTH)) | |
| 102 | +}' | |
| 99 | 103 | |
| 100 | 104 | isdnctrl 2>&1 | grep version | awk \ |
| 101 | 105 | 'NR==1{print "isdn4k-utils ", $NF}' |