Does KSH support data type conversion?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Does KSH support data type conversion?
# 1  
Old 06-25-2007
Does KSH support data type conversion?


Hello,everyone here.
I'm coding with KSH to achieve exploring the disk space and judging whether it closes to overflow.But It seems that no one way to convert a string variable to integer.

Code:
df | read A B C D E F G H I J K L  
print ${L}

Can I convert L to integer type?

Thanks for your help on this issue.
# 2  
Old 06-26-2007
In shell script there are no data types.
# 3  
Old 06-26-2007
Whith KSH, it's possible to declare an integer variable :
Code:
typeset -i var

You will get an error if you try to assign a non numeric value to this variable.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Logical Error With Type Conversion In C

So, I'm into about 650 lines of some code I'm working on. So I'll try to explain instead of flooding this post. Say I have some code like this: int main() { int i, j; char data; printf("Gimme something: "); fgets(data, INPUT_BUFF, stdin); for (j = 0; j < data; j++){... (6 Replies)
Discussion started by: Azrael
6 Replies

2. Shell Programming and Scripting

KSH - type ENTER to continue

Hello, Is ther any way to run a loop which promt an echo"waiting for user to hit ENTER" sleeps for an iterval and once user hit the ENTER key the loop exit and the script continue to the next stage? I need this ASAP !!! Thanks!! (9 Replies)
Discussion started by: LiorAmitai
9 Replies

3. Programming

type conversion C, atoi()

In the book "The C programming language"; second edition, chapter 2.7 there is a snippet which is supposed to: "convert a string of digits into its numeric equivalent". int atoi(char s) { int i, n; n = 0; for ( i = 0; s >= '0' && s <= '9'; ++i) n = 10 * n + (s -... (4 Replies)
Discussion started by: tornow
4 Replies

4. Shell Programming and Scripting

Military type format date/time conversion

Hello All, I have a requirement to convert a 12 hour format to 24 hour time format and the sample input /out put is below Input Time format : Nov 2 2011 12:16AM Out Put Format : Nov 2 2011 0:16 Input : Nov 2 2011 4:16PM Out Put: Nov 2 2011 16:16 I have done this using a... (6 Replies)
Discussion started by: jambesh
6 Replies

5. Shell Programming and Scripting

ksh : find value type

Hi, Simple question : How to find the value type from a variable : Ex : var="1" => type is numeric var="a" => type is character Thx :D (3 Replies)
Discussion started by: madmat
3 Replies

6. Shell Programming and Scripting

Timestamp to date conversion in ksh

Hi, I have a file containing timestamp( Example given below). How can i get date(mmd-dd-yyyy) from it? ($> cat file1.txt 2008-11-24 05:17:00.7043) Thanks, Sri (2 Replies)
Discussion started by: srilaxmi
2 Replies

7. Shell Programming and Scripting

Perl in KSH - julian conversion

Hello Everyone, I have this code misbehaving in one of my scripts, I have a var containing the sequential number of the day for the year and I am suppose to get the regular date for that day and its weekday. If I set the day to 273 I get back 2008/09/31 which is not a proper date. can you help... (7 Replies)
Discussion started by: gio001
7 Replies

8. UNIX for Advanced & Expert Users

changing shell type from sh to ksh

Could someone please advise, what's the best way to changing the shell type from sh to ksh. When I login into a unix server it takes you directly to sh, is there a way of amending the .profile to use ksh instead. Or is there some other way ? Ideally it would be good to be done from the login... (10 Replies)
Discussion started by: venhart
10 Replies

9. Shell Programming and Scripting

Conversion question about ksh

Hi all, New to ksh and had a few questions to see if this is doable in ksh or if I am going to have to call out to a tcl procedure. I have an Ascii file I want to convert to hex then search and remove all hex chars '0A' and then convert back to Ascii. Here is an example of an Ascii file I am... (2 Replies)
Discussion started by: hgjdv
2 Replies

10. Shell Programming and Scripting

csh -> ksh conversion question

Having been a long-time csh person I now need to convert a lot of stuff to run under ksh. Can anyone tell me how to do a ksh equivalent of the csh history substitution !* that can be used in an alias, ie how would I do: alias cd "cd \!*; pwd" alias find "find . -name... (2 Replies)
Discussion started by: jonnywilkins
2 Replies
Login or Register to Ask a Question