Shell Script to Validate Integer Input Last Updated : 09 Apr, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Here we are going to see a shell script which validates an integer. We are going to display whether the input entered is an integer or an invalid input. Approach: Take input from the user.Store the input of any variableNow we are going to trim the input in such a way that all the -(minus) or +(plus) signs before the input are trimmed down.Now we are going to apply a regular expression to check if the input pattern has multiple occurrences of digits 0-9.If the input pattern contains only digits, this means that the input entered is a valid integer and in all other cases, invalid integer input is shown. The Shell Script is given below: # Asking the user to enter an input echo "Enter an input" # reading and storing input read variable # Applying the approach given above case ${variable#[-+]} in *[!0-9]* | '') echo "Not an integer" ;; * ) echo "Valid integer number" ;; esac Output: Output of the above code snippet Comment More infoAdvertise with us Next Article Shell Script to Validate Integer Input C chinmay_bhide Follow Improve Article Tags : Linux-Unix Shell Script Similar Reads Shell Script To Check For a Valid Floating-Point Value User Input can be hectic to manage especially if it's about numbers. Let's say you wanted to perform mathematical calculations in your app or script. It's not hard to say that it will have to deal with floating-point numbers. It's easy in many statically typed programming languages but if it has to 4 min read Shell Script Program to Demonstrate the '$#' Variable In Linux, if we want to count the total number of arguments that are passed to the specific script then we can use the "$#" variable. This variable stores the total count of arguments, the program properly tracks and reports the number of arguments passed at the runtime of the script. Along with thi 5 min read Shell Script to validate the date, taking into account leap year rules Prerequisites: Bash Scripting, Shell Function Library We will build a bash script to check whether the entered date is valid or not according to the Gregorian Calendar rules. If the date is invalid, the script will tell the reason for its invalidity. The script takes three arguments - day, month, an 5 min read How to Validate Decimal Numbers in JavaScript ? Validating user input is an essential aspect of Web Development. As a developer, when we are playing with the numeric inputs provided by the end-user, it is quite important to ensure that the input provided by the user is in the correct format. We can use the regular expression to Validate Decimal N 2 min read Shell script to print table of a given number In this article, we will explore the process of creating a simple yet powerful shell script that takes user input and generates number tables. Number tables are a common mathematical concept used to display the multiples of a given number up to a specified limit. We will illustrate this process with 2 min read Like