typeset and export command difference


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers typeset and export command difference
# 1  
Old 05-16-2006
typeset and export command difference

Can anyone please explain what the difference is between these two commands

typeset - ?

export - i know with this even child process can read the variable

Declare - ?

i use bash shell

http://cnswww.cns.cwru.edu/~chet/bas...ref.html#SEC58
states that
"
The typeset command is supplied for compatibility with the Korn shell; however, it has been deprecated in favor of the declare builtin command. "

Which one should i use to set variables

Is typeset/declare meant for declaring variables in functions ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Typeset command issue

Hi, As per my understanding typeset wil lmake a variable constant or readonly and -i option will make a variable integer. But please see the below outputs typeset -i abc=000001;echo $abc 1 typeset -i abc=0000010;echo $abc 8 typeset -i abc=00000100;echo $abc 64 typeset -i... (3 Replies)
Discussion started by: ratheeshjulk
3 Replies

2. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

3. Shell Programming and Scripting

Struck with Typeset Command

Can someone explain whats this below command will do exactly.. typeset tmpFile1 tmpDir1 rc fileName fullName bc typeset tmpFile1 tmpFile2 rc fileSuffix uef typeset origFile bc fullName tmpDir1 remoteCmd inFile newInFile typeset num fn curDate fileSuffix ucFileName Since i'm new to... (1 Reply)
Discussion started by: help_scr_seeker
1 Replies

4. Shell Programming and Scripting

how the typeset command works in shell script

typeset -l section section=${2:-.} what does these 2 lines meaning? (1 Reply)
Discussion started by: venkatababu
1 Replies

5. Shell Programming and Scripting

Error while using typeset command

I am having a problem with typeset command: It is behaving differently in different machines. Machine 1: /marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>echo $0 -bash /marc_data/marc_project/owb_marc_adaptor/owb_marc_adaptor_load/bin>vi fn2.ksh... (6 Replies)
Discussion started by: boopathyvasagam
6 Replies

6. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

7. Shell Programming and Scripting

use of set, export and typeset

what is the difference in usage of set, export, typeset while declaring a value to a variable can any one help thanks (0 Replies)
Discussion started by: trichyselva
0 Replies

8. UNIX for Dummies Questions & Answers

difference between EXPORT and setenv

Hi, Is there any difference between setting an environment variable by EXPORT and by setenv? (3 Replies)
Discussion started by: dexkid
3 Replies

9. UNIX for Dummies Questions & Answers

difference between set and export

Hi, can anybody tell me what is the difference between set and export in unix. -Ashish (1 Reply)
Discussion started by: shriashishpatil
1 Replies

10. UNIX for Dummies Questions & Answers

export command

Is there any difference between these 2 commands :- export var="a" and var="a" export var (2 Replies)
Discussion started by: radhika03
2 Replies
Login or Register to Ask a Question
typeset(1)                                                         User Commands                                                        typeset(1)

NAME
typeset, whence - shell built-in functions to set/get attributes and values for shell variables and functions SYNOPSIS
typeset [ +- HLRZfilrtux [n]] [ name [ = value]]... whence [-pv] name... DESCRIPTION
typeset sets attributes and values for shell variables and functions. When typeset is invoked inside a function, a new instance of the variables name is created. The variables value and type are restored when the function completes. The following list of attributes may be specified: -H This flag provides UNIX to host-name file mapping on non-UNIX machines. -L Left justify and remove leading blanks from value. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. When the variable is assigned to, it is filled on the right with blanks or trun- cated, if necessary, to fit into the field. Leading zeros are removed if the -Z flag is also set. The -R flag is turned off. -R Right justify and fill with leading blanks. If n is non-zero it defines the width of the field, otherwise it is determined by the width of the value of first assignment. The field is left filled with blanks or truncated from the end if the variable is reas- signed. The -L flag is turned off. -Z Right justify and fill with leading zeros if the first non-blank character is a digit and the -L flag has not been set. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. -f The names refer to function names rather than variable names. No assignments can be made and the only other valid flags are -t, -u and -x. The flag -t turns on execution tracing for this function. The flag -u causes this function to be marked undefined. The FPATH variable will be searched to find the function definition when the function is referenced. The flag -x allows the func- tion definition to remain in effect across shell procedures invoked by name. -i Parameter is an integer. This makes arithmetic faster. If n is non-zero it defines the output arithmetic base; otherwise, the first assignment determines the output base. -l All upper-case characters are converted to lower-case. The upper-case flag, -u is turned off. -r The given names are marked readonly and these names cannot be changed by subsequent assignment. -t Tags the variables. Tags are user definable and have no special meaning to the shell. -u All lower-case characters are converted to upper-case characters. The lower-case flag, -l is turned off. -x The given names are marked for automatic export to the environment of subsequently-executed commands. The -i attribute can not be specified along with -R, -L, -Z, or -f. Using + rather than - causes these flags to be turned off. If no name arguments are given but flags are specified, a list of names (and optionally the values) of the variables which have these flags set is printed. (Using + rather than - keeps the values from being printed.) If no names and flags are given, the names and attributes of all variables are printed. For each name, whence indicates how it would be interpreted if used as a command name. The -v flag produces a more verbose report. The -p flag does a path search for name even if name is an alias, a function, or a reserved word. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), set(1), sh(1), attributes(5) SunOS 5.10 1 Feb 1995 typeset(1)