Sponsored Content
Top Forums Shell Programming and Scripting Is there any way to makesure that the input from the user is all numbers? Post 14108 by Jimbo on Monday 28th of January 2002 11:21:24 AM
Old 01-28-2002
if expr "$answer" : "[0-9]*$" > /dev/null ; then
echo 'all digits'
else
echo 'NOT all digits'
fi
Jimbo
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Accept user input - only numbers

I have a situation where I want the user to enter only numbers in response to a READ command. I have some validation to restrict the number to be between 1 and 12, but if the user type in some characters the script echoes some error message and goes to the next command. Below is a snippet of the... (1 Reply)
Discussion started by: pvar
1 Replies

2. UNIX for Dummies Questions & Answers

Negative Numbers for input parameters.

Hello, I have a command that I need to supply a negative number as a parameter; how do I do this? I have tried giving it with double quotes, "", but no avail. Thanks, Gussi (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

3. Shell Programming and Scripting

Constructing numbers from input lines

I have a file with the information shown and I want to capture the entry having the rgdt tag and taking the value (the location of the represents the decimal point, for example 0p50 represents 0.50) I then want to divide the number at the end of each line by the value 0.50 I want to do... (7 Replies)
Discussion started by: kristinu
7 Replies

4. Shell Programming and Scripting

input of two numbers in the middle of the script

Hi, My script ask for the input of two numbers in the middle of it. I would like to know how to indicate this two numbers when I submit the script. thanks for any help, jalves (4 Replies)
Discussion started by: jalves
4 Replies

5. UNIX for Dummies Questions & Answers

Extraction of numbers from input

I have the following input: xxxx-2.7.19_WR3 I have extract the following: 2.7.19 Can anyone suggest an awk or sed command to do the above...:confused: another condition is if the input is : xxx-xxx_xxx-1.4-1_WR3.0bg.armv6jel_vfp it shud still extract : 1.4-1 whenever "-"... (12 Replies)
Discussion started by: xerox
12 Replies

6. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

7. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

8. Shell Programming and Scripting

Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

I have a file full of coordinates of the form: 37.68899917602539 58.07500076293945 57.79100036621094 The numbers don't always have the same number of decimal points. I need to reduce the decimal points of all the numbers (there are 128 rows of 3 numbers) to 2. I have tried to do this... (2 Replies)
Discussion started by: crunchgargoyle
2 Replies

9. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies
UNITS-FILTER(1) 					     units-filter User Manual						   UNITS-FILTER(1)

NAME
units-filter - is a parser for physical and chemical quantities SYNOPSIS
units-filter -s -o -l DESCRIPTION
units-filter is a basic standalone parser written in C language, flex and bison. It inputs strings like "1.5e3 nN.m.s^-1" (it could be the time growth ratio of a torque) and outputs the value in standard SI unit, followed by the physical dimension of this value. OPTIONS
-s Like Significant. Takes in account the number of significant digits. For example 1.0 m contains 2 significant digits, while 0.00100 contains 3 significant digits. It is possible to enforce the number of significant digits by using a special syntax : if units-filter parses the input "1.0m#6", it interprets it as a value with exactly 6 significant digits, like "1.00000 m". The number following the # sign is the forced number of significant digits. The number of significant digits appears just before the last zero in the output of the command (this zero is a placeholder for future extensions). -o Like Output. Outputs a correct representation of the physical quantity with its physical unit in the International System notation. There may be some simplification with usual units. For example, a newton will be represented by the unit N in place of m.kg.s^-2. The value is expressed as a floating number with one digit before the decimal point, and as many digits in the mantissa as necessary to fit the desired number of significant digits (see an example below). It is possible to enforce the output unit : just add a colon and the desired unit at the end of the input. If this unit is homogeneous with the former one, it will be used to format the output. -l Like LaTeX. Outputs a correct representation of the physical quantity with its physical unit in the International System notation, in LaTeX language. EXAMPLES
Establish the SI value and unit exponent of a quantity in the mksa system: ~$ echo 1.5e3 nN.m.s^-1 | units-filter 1.5e-6 2 1 -3 0 0 0 0 which means : 1.5e-6 (SI unit) m^2.kg.s^-3 Compare different physical quantities: ~$ e1=$(echo "1.2e-3 V" | units-filter) ~$ e2=$(echo "1200e3 nWb/s"| units-filter) ~$ if [ "$e1" = "$e2" ]; then echo ok; else echo ko; fi ok ... which emphasizes that webers by unit time are the same as volts. Playing with the number of significant digits: ~$ echo "0.00100m" | src/units-filter -s 0.001 1 0 0 0 0 0 0 3 0 ~$ echo "0.00100m #2" | src/units-filter -s 0.001 1 0 0 0 0 0 0 2 0 Giving a value for the relative precision: ~$ echo "1kV~2" | units-filter -o 1e+03 V +-2% Turning on the LaTeX output: ~$ echo "1kohm+-2%" | units-filter -l 1 imes 10^{+03}, Omega pm 2,\% Turning on the output of a canonical physical notation: ~$ echo "1.0 m.kg.s^-2 #7" | units-filter -o 1.000000e+00N Choosing a non-standard unit for the output: ~$ echo 1800C:A.h| units-filter -o 5.000e-01 A.h KNOWN BUGS
Few units out of the mksa system are successfully parsed. AUTHOR
Georges Khaznadar <georgesk@ofset.org> Wrote this manpage. COPYRIGHT
Copyright (C) 2009 Georges Khaznadar Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. units-filter 11/19/2011 UNITS-FILTER(1)
All times are GMT -4. The time now is 07:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy