Typeset issues


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Typeset issues
# 1  
Old 01-19-2007
Data Typeset issues

data contains:

1 ;1
500;2
10 ;6
111;9
100;0
20 ;1
2 ;5
and so on............

The program codes:

#!/usr/bin/ksh
echo "Please enter id1"
read n
echo "please enter id2"
read m
typeset -L3 n
grep "$n;$m" data > $n-x


The issues:

If I enter 500 for id1 and 2 for id2, I will get a Valid file "500-x" that contain 500;2.
If I enter 1 for id1 and 1 for id2, I will get an invalid file "1 -x" which I can not cat; I get these messages when I cat the file:
cannot open 1
cannot open -x

The questions:

Are there ways to get around this problem? Since I typeset -L3 n to get the data pattern that I need to grep. How can I un-typeset it when want to save it as a file?

When I enter 1 for id1 and 1 for id2; I need to have a file "1-x" as a valid file and when I cat it I should get: 1 ;1

The experts answers?


Many thanks!!!
# 2  
Old 01-19-2007
I would use two variables:
typeset -L3 n2=$n
and then is n2 or n as required.
# 3  
Old 01-20-2007
MySQL it works

Thanks for the help! I see how it works but I don't understand the coding..Can you please explain? Are there other ways beside this coding?
# 4  
Old 01-20-2007
Not sure what to explain...but
typeset -L3 n2
n2=$n
would be another way to do it.
# 5  
Old 01-20-2007
MySQL I got it!

Thanks! I see it now!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Typeset

I don't have man typeset entry in unix. what is the use of typeset command and can you give some examples for that. (1 Reply)
Discussion started by: ramkumar15
1 Replies

2. Shell Programming and Scripting

Why use typeset?

Hi, All the scripts we have here use typeset instead of normal variables. They don't have any parameters, they just get declared at the beginning of the scripts like this: typeset var1 var2 var3Could anyone tell me why this is done? I don't see the advantage in this over using normal variables. (1 Reply)
Discussion started by: Subbeh
1 Replies

3. UNIX for Dummies Questions & Answers

Typeset

Hi, Can any one please explain me the use of 'typeset' in shell scripting? I donot under stand the use and advantages of using typeset. In one of our script, it is written like typeset VERBOSE NO_UPDATE typeset LOAD_SYBASE_TABLES I donot understand what actually these lines do. As per my... (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

4. UNIX and Linux Applications

typeset-r

Hi All , Can any one help me the meaning of typeset -r Thanks, venkat (1 Reply)
Discussion started by: venkatakotiy
1 Replies

5. Shell Programming and Scripting

Typeset

Hi, Could any one please explain about typeset or share any link from where i can study about typeset i.e how to use it, how to define it.. etc? Thanks- Yogi (3 Replies)
Discussion started by: bisla.yogender
3 Replies

6. Shell Programming and Scripting

typeset

Can anyone show me a simple practical usage of typeset. (1 Reply)
Discussion started by: balaji_prk
1 Replies

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

8. Shell Programming and Scripting

typeset -f ???

I have found this command *typeset* and the option * -f *, which should provide me the list of all the currently defined functions. Is there any possibility of specifying the file in which this command to search ? (1 Reply)
Discussion started by: xinfinity
1 Replies

9. UNIX for Dummies Questions & Answers

TYPESET use

Hi all, I have problem understanding shell script.Written that $bindir/put_load.ksh ; typeset RV= $? I dont have any other document about script. How can i find that $bindir is exist or not what is the content of that, i am working on new box . how can i search that in old box what... (4 Replies)
Discussion started by: sam71
4 Replies
Login or Register to Ask a Question