Created
April 16, 2011 14:45
-
-
Save noqqe/923159 to your computer and use it in GitHub Desktop.
Replace Unix tools with bash interna
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/statistical b/statistical | |
| index 50f443c..17423b3 100755 | |
| --- a/statistical | |
| +++ b/statistical | |
| @@ -20,11 +20,11 @@ fi | |
| for data in $SUM; do | |
| # Getting informations from parameters | |
| - KEY=$(echo $data | awk -F: '{printf $1}') | |
| - VALUE=$(echo $data | awk -F: '{print $2}') | |
| - | |
| + KEY=${data%%:*} | |
| + VALUE=${data##*:} | |
| + | |
| # Fishing errors from wrong usage | |
| - if $(echo $VALUE | grep -q -v -P '^\d{1,}$'); then | |
| + if [[ ! $VALUE =~ ^[[:digit:]]+$ ]]; then | |
| echo "ERROR: Do not use characters as value! Key:$KEY" | |
| exit 1 | |
| fi | |
| @@ -71,9 +71,8 @@ done | |
| # Start graphing | |
| for data in $SUM; do | |
| - KEY=$(echo $data | awk -F: '{printf $1}') | |
| - REAL_KEY=$KEY | |
| - VALUE=$(echo $data | awk -F: '{print $2}') | |
| + KEY=${data%%:*} | |
| + VALUE=${data##*:} | |
| REAL_VALUE="$VALUE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment