Typeset conversion problem from ksh to bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Typeset conversion problem from ksh to bash
# 1  
Old 03-04-2010
Typeset conversion problem from ksh to bash

Hi,

Code:
typeset -l sgf  # all lowercase letters
typeset -u SGF  # all uppercase letters
sgf=$1
SGF=$sgf

these lines used in my scripts . It ran fine in ksh but when we convert this to bash it erroring out.

I like to know what the use of typeset ??

Thanks & Regards
kanagaraj

Last edited by radoulov; 03-05-2010 at 10:10 AM.. Reason: Please use code tags!
# 2  
Old 03-05-2010
Which bash version are you using?

Last edited by radoulov; 03-05-2010 at 02:41 PM.. Reason: English ...
# 3  
Old 03-05-2010
Hi,

In bash we can use decare instead of typeset but its options is limited.
Code:
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]

I used functions , its worked fine
Code:
toUpper() { echo $1 | tr "[:lower:]" "[:upper:]" } GENDER=male GENDER=`toUpper $GENDER` echo $GENDER
toLower() { echo $1 | tr "[:upper:]" "[:lower:]" } GENDER=MALE GENDER=`toLower $GENDER` echo $GENDER

Thnks,
kanagaraj

Last edited by radoulov; 03-05-2010 at 11:04 AM.. Reason: Code tags, please!
# 4  
Old 03-05-2010
Hi.

Two data points: typeset -l and typeset -u seem to work correctly in:
Code:
GNU bash 4.0.35

but not in:
Code:
GNU bash 3.2.39

cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh "typeset -i" and Empty Parameters

I'm getting different behaviors for "typeset -i" on different systems. In one case unset parameters are 0, and in another case they're empty. Is one of these behaviors correct, or is the behavior here unspecified? First system: $ typeset -i x $ print $x 0 $ print ${.sh.version} Version M... (13 Replies)
Discussion started by: Matt Miller
13 Replies

2. Shell Programming and Scripting

Bash to ksh problem

Hi all Below code works in bash but it is not working in ksh. enddate=`date -d "$enddate + $i day" "+%Y_%m_%d"` Please help me how it works in ksh Thanks (10 Replies)
Discussion started by: pmreddy
10 Replies

3. Shell Programming and Scripting

converting ksh to bash - typeset commands

Hi all, Am trying to convert a script written in ksh to a bash shell. At the moment, am stumped with the typeset -u command and I can't find an equivalent of it in bash. integer function is also not working as is the following if statement if ] && ]; then continue fi Is... (3 Replies)
Discussion started by: newbie_01
3 Replies

4. Shell Programming and Scripting

bash & Ksh loop problem

hi i was trying to optimize one script and i came across this problem .. i am putting some pseudo code here $ >cat a.sh ls | while read I do i=$(($i + 1)) done echo "total no of files : " $ >ksh a.sh total no of files : $ >bash a.sh total no of files : why is... (1 Reply)
Discussion started by: zedex
1 Replies

5. Shell Programming and Scripting

bash typeset padding with zeros

Hi everybody, I have a question about typesetting. I originally wrote a script for use with ksh and now I am on a system that I cannot modify, and it only has bash. In the original script I just did typeset -RZ4 variable and it would add the leading zeros. In bash, it doesn't work. I've... (2 Replies)
Discussion started by: jwheeler
2 Replies

6. Shell Programming and Scripting

Help with typeset in bash

Hi everybody, hoping you can help. I'm trying to get some scripts working using bash which were written in ksh and I'm struggling with typeset. Specifically typeset -R and typeset -L. We need fixed length variables with left and right justification and bash does not seem to do it. Spent ages on... (5 Replies)
Discussion started by: Ian_H
5 Replies

7. 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

8. UNIX for Dummies Questions & Answers

typeset in Ksh

Hi, Most of times, I see use of typeset command in ksh scripts, but I don't know what it exactly does. I would be thankful if any body could provide me a brief explanation of typeset in ksh and all of its options, like typeset -A, typeset -r, typeset -Z, typetset -L etc. (5 Replies)
Discussion started by: nervous
5 Replies

9. Shell Programming and Scripting

Problem with Darwin typeset -i

From the bash manpage: typeset ] What I'm trying to do is add two values in hexadecimal and have the resulting number display in hexadecimal. What I get is the result displayed in decimal. For instance: a=0x10 b=0x30 ((c=a+b)) echo $c ...displays 64. The arithmatic is correct, but the... (2 Replies)
Discussion started by: Loriel
2 Replies
Login or Register to Ask a Question