From fee1961eedf54acadd9a9d8231b052c5317534ba Mon Sep 17 00:00:00 2001 From: mboelen Date: Wed, 30 Sep 2015 18:34:16 +0200 Subject: [PATCH] Added DigitsOnly function to extract only numbers from a text string --- include/functions | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/functions b/include/functions index ae4b75ed..bf58667b 100644 --- a/include/functions +++ b/include/functions @@ -25,6 +25,7 @@ # CheckUpdates Determine if a new version of Lynis is available # counttests Count number of performed tests # Debug Display additional information on the screen (not suited for cronjob) +# DigitsOnly Return only the digits from a string # DirectoryExists Check if a directory exists on the disk # Display Output text to screen with colors and identation # ExitClean Stop the program (cleanly), with exit code 0 @@ -181,6 +182,23 @@ if [ ${DEBUG} -eq 1 ]; then echo "DEBUG: $1"; fi } + ################################################################################ + # Name : DigitsOnly + # Description : Only extract numbers from a string + # Returns : Digits only string + ################################################################################ + + DigitsOnly() + { + VALUE=$1 + logtext "Value is now: ${VALUE}" + if [ ! "${AWKBINARY}" = "" ]; then + VALUE=`echo ${VALUE} | grep -Eo '[0-9]{1,}'` + fi + logtext "Returning value: ${VALUE}" + #return $VALUE + } + # Display text Display() {