shell to number and to string

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell to number and to string
# 1  
Old 11-06-2001
Computer shell to number and to string


Does the unix korn shell provide a function to convert between number and string data-types

# 2  
Old 11-06-2001
It doesn't need one. ksh will do arithmetic with string variables that happen to contain numbers. But if you really want to do this, just use a replacement statement:
#! /usr/bin/ksh
integer i

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies

2. Shell Programming and Scripting

Korn Shell manipulating the string into dynamic currency number

Conversion of string into currency value.. ex1: number_of_positions=2 input_string=345987 Output= 345,987.00 ex2: number_of_positions=4 input_string=1345987 Output= 1,345,987.0000 Please respond as soon as possible edit by bakunin: we will gladly respond as soon as... (15 Replies)
Discussion started by: suren.bills
15 Replies

3. Shell Programming and Scripting

Getting number from a string

I have a string c12 and want to get the number 12 In general instead of 12 I can have any number. I have to capture the number as I need to do some computations on it. I am using a bash script (6 Replies)
Discussion started by: kristinu
6 Replies

4. UNIX for Dummies Questions & Answers

Comparing a String variable with a string literal in a Debian shell script

Hi All, I am trying to to compare a string variable with a string literal inside a loop but keep getting the ./ line 6: #!/bin/sh BOOK_LIST="BOOK1 BOOK2" for BOOK in ${BOOK_LIST} do if then echo '1' else echo '2' fi done Please use next... (1 Reply)
Discussion started by: daveu7
1 Replies

5. UNIX for Dummies Questions & Answers

converting string to number in shell script

Hi, I am having a problem in converting a string to number so I can preform arithmetic operations. timeTot=0 timeTmp=$(cat idsOutput | grep 'Run time' | cut -c 36-39) timeTot=$ #This is line 28 echo "total RunTime=" $timeTot this is the error msg: ./ line 28: 0+1.35: syntax... (8 Replies)
Discussion started by: turki_00
8 Replies

6. Shell Programming and Scripting

changing number in bash (number is in form of string)

I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as name1:name2:name3:1 when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Discussion started by: Learnerabc
3 Replies

7. Shell Programming and Scripting

Shell Script to identify the line number containing a particular "string"

Hi, I have a log file, where i am required to identify the line number, where a particular string/line appears in the log file. And then copy 200 lines above that line number to a new file. Can someone provide pointers on how to write this script or what command to be used ? Any... (2 Replies)
Discussion started by: kk2202
2 Replies

8. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

9. Shell Programming and Scripting

How to Check given string is number in shell script?

Hi, Can anyone help me out to check whether the input argument is number? Example: REQUEST_ID="123456" I need to check the REQUEST_ID value is number or string. Thanks in Advance Regards BS (6 Replies)
Discussion started by: balajiora
6 Replies

10. Shell Programming and Scripting

string to number

In the following script when I get SIZE1 and SIZE2, they are of type string. I can not do any mathematical operations on them. I wanted to find out if I can convert string in to Number. Thanks in Advance. FILE1='/export/registry/incoming/reg.dmp' FILE2='/export/registry/reg.dmp' SIZE1=`ls... (2 Replies)
Discussion started by: George_king
2 Replies
Login or Register to Ask a Question