How do one evaulate a variable's value if it is number or not


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do one evaulate a variable's value if it is number or not
# 1  
Old 04-20-2007
How do one evaulate a variable's value if it is number or not

How do one evaulate a variable's value if it is number or not. say
var1=1234;
....
I want to check if $var1 contains a number or not. Is there any built-in command or combination of commands available?

Thanks,
Suman
# 2  
Old 04-20-2007
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get letter from number and assign to a variable

Hi to all in forum, I'm trying to convert the letter number between 1 (A) and 26 (Z), that part is working, my issue is how to assign the printf output to a variable:LetterNumber=10 printf "\x$(printf %x $((${LetterNumber}+64)))" $ J #The problem, how to assign printf output (J in this... (8 Replies)
Discussion started by: Ophiuchus
8 Replies

2. Shell Programming and Scripting

trying to accumulate a number in the same variable

Hello, I trying to accumulate the same number in a variable: #!/usr/bin/sh infile="$1/$2" if ] then #echo "file is not readable: $infile" exit 1 fi awk ' { num_cols=NF; # the number of columns in the current line temp_cols=temp_cols+num_cols #add up... (1 Reply)
Discussion started by: script_op2a
1 Replies

3. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

4. Shell Programming and Scripting

Counting number of commas(,) in a variable

Hi all, I am having problems counting commas (,) from a variable in shell scripting.. the variable contains similiar to: ID@NAME@DESCRIPTION,ID@NAME@DESCRIPTION, ..... It can go on and on.. So i need to count the number of sets i.e.( ID@NAME@DESCRIPTION is one set) and process the... (4 Replies)
Discussion started by: faelric
4 Replies

5. Shell Programming and Scripting

how to add Loop number to variable name?

Hi there, I need to add a sequence of numbers to existing variables within the script to be able to call the variable automatically. Somehow it's just printing the loop number. Here's what I've got so far. :eek: #!/bin/sh FOLDER1=foo FOLDER2=bar FOLDER3=beer for ((a=1; a <= 3 ; a++))... (2 Replies)
Discussion started by: siul0_0
2 Replies

6. UNIX for Dummies Questions & Answers

appending variable number of files

In a particular path of a server I have number of files.The files are generated every date with a date_mth stap on this.There are different files for different clients. For example in /data1 path i have X_0416_Score Y_0416_Score Z_0417_Score X_0417_Score A_0417_Score If i will run the... (1 Reply)
Discussion started by: dr46014
1 Replies

7. Shell Programming and Scripting

declare number variable in csh

Hi frind, i="1" while do echo "i is $i" data_file=$HYP_ROOT/import/efcextr$i.txt echo "$data_file" i=`expr $i + 1` done This is woring finly in ksh but not in ksh. in ksh it showing error i=1: Command not found i: Undefined variable Kindly help me ...why it is showing the error... (1 Reply)
Discussion started by: deep_kol
1 Replies

8. Shell Programming and Scripting

Export variable as number

Hi Guys, I am using the korn shell. I have an environments files where I have defined a variable export START_TIME=060000 export END_TIME=220000 I source this environments file into one of my scripts. The problem is that when I try to use this variable, I cannot get to use this variable as a... (2 Replies)
Discussion started by: zeus101
2 Replies

9. UNIX for Dummies Questions & Answers

check whether variable number or string

I am passing an argument to a file and i wanna check whether the argument is a number or string ? how can i do this? (4 Replies)
Discussion started by: rolex.mp
4 Replies

10. UNIX for Dummies Questions & Answers

Check if variable is a number

If I have a variable $X, how do I check it is a number? Many thanks. (2 Replies)
Discussion started by: handak9
2 Replies
Login or Register to Ask a Question