Sponsored Content
Top Forums Shell Programming and Scripting Refering to compound variables with a variable name Post 302740061 by luky55 on Wednesday 5th of December 2012 12:04:40 PM
Old 12-05-2012
Thanks, the typeset -n or nameref works great
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compound expression in unix

I am using the code below to write a command to launch a script only if the number of users on the system is less than 10. The code below isn't working. Any suggestions? HELP.. if && ; then frizzle ; fi (3 Replies)
Discussion started by: spalmer
3 Replies

2. Shell Programming and Scripting

Trying to use 'compound variable' in a script

Hi there - am newish to shell scripting and would appreciate some advice on this... Am trying to use what I have seen called 'compound variables' in other langs but with no success in my shell script. This is the kind of thing I'm trying to do: base_val=123 stop=3 x=1 while do ... (3 Replies)
Discussion started by: neemic
3 Replies

3. Shell Programming and Scripting

Trying to use 'compound variable' in a script

Erase the space in assigment operator. array_var=`expr $base_val + $x` (1 Reply)
Discussion started by: irina
1 Replies

4. UNIX for Advanced & Expert Users

Compound indirect variable references

Using bash, I'm trying to read a .properties file (name=value pairs), assigning an indirect variable reference for each line in the file. The trick is that a property's value string may contain the name of a property that occurred earlier in the file, and I want the name of the 1st property to... (5 Replies)
Discussion started by: tkrussel
5 Replies

5. Shell Programming and Scripting

Compound command with 'find' utility?

I'm trying to write a script using the 'find' command and it's -exec option to run a compound command against the files found. Example: find . -name "*.conf" -exec cat {} | grep "#" > /tmp/comments.list \; Of course the above doesn't work. So I experimented for a bit to see if there was... (6 Replies)
Discussion started by: deckard
6 Replies

6. Shell Programming and Scripting

awk compound statements

how can i use two or multiple statements in the if part of an awk code for example i want to check two flag if they are true i will write some print operations and increase the counter. here is the c version of the code that i want to write: counter=0; if (flag1==1 && flag2==0) {... (7 Replies)
Discussion started by: gfhgfnhhn
7 Replies

7. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 (0 Replies)
Discussion started by: ZINGARO
0 Replies

8. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 fild1 ) but this sintax in ksh and sh (HP-UNIX) not work... why?? exist another solution for this type of variable ??? (5 Replies)
Discussion started by: ZINGARO
5 Replies

9. Shell Programming and Scripting

compound Bash if then statement question

I am writing a Bash script that will either clone a database or setup a standby database. So Parameter 2 will be the operation type. If the value is not clone or standby I want to throw an error message. I suppose I can also do a case block. So far i have been unable to get the syntax working... (1 Reply)
Discussion started by: gandolf989
1 Replies

10. Programming

tcl compound condition

Can anyone explain for me why this does not work in tcl: if !{( $a > "" || $b > "" )} { ....... where a and b are string vars. and this works instead: if {!( $a > "" || $b > "" )} { ........ Thanks. (6 Replies)
Discussion started by: gio001
6 Replies
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... ksh93 ++typeset [+-AHflbnprtux] [+-EFLRZi[n]] [vname[=value]] whence [-afpv] name... DESCRIPTION
ksh 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 can be specified: -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 is searched to find the function definition when the function is referenced. The flag -x allows the function definition to remain in effect across shell procedures invoked by name. -H This flag provides UNIX to hostname file mapping on non-UNIX machines. -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 uppercase characters are converted to lowercase. The uppercase flag, -u is turned off. -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 truncated, 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 The specified names are marked readonly and these names cannot be changed by subsequent assignment. -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 reassigned. The -L flag is turned off. -t Tags the variables. Tags are user definable and have no special meaning to the shell. -u All lowercase characters are converted to uppercase characters. The lowercase flag, -l is turned off. -x The specified names are marked for automatic export to the environment of subsequently-executed commands. -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. 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 specified 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 specified, 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 manual 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 variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ksh93 If the -f option is not specified, typeset sets, unsets, or displays attributes of variables as specified with the options. If the first option is specified with a - then the attributes are set for each of the specified names. If the first option is specified with a +, then the specified attributes are unset. If =value is specified, value is assigned before the attributes are set. When typeset is called inside a function that is defined with the function reserved word, and name does not contain a ., a local variable statically scoped to that function is created. Not all option combinations are possible. For example, the numeric options -i, -E, and -F cannot be specified with the justification options -L, -R, and -Z. The following preset aliases are set by the shell: float typeset -E functions typeset -f integer typeset -i nameref typeset -n If no names are specified, variables that have the specified options are displayed. If the first option is specified with a leading - then the name and value of each variable is written to standard output. Otherwise, only the names are written. If no options or only the -p option are specified, the names and attributes of all variables that have attributes are written to standard output. When -f is specified, the names displayed are function names. If -f is specified, then each name refers to a function and the only valid options are -u and -t. In this case no =value can be specified. typeset is built-in to the shell as a declaration command so that field splitting and pathname expansion are not performed on the argu- ments. Tilde expansion occurs on value. The following options are supported by the typeset built-in command in ksh93: -a Indexed array. This is the default. -A Associative array. Each name is converted to an associative array. If a variable already exists, the current value becomes index 0. -b Each name can contain binary data. Its value is the mime base64 encoding of the data. This option can be used with -Z, to specify fixed sized fields. -E [n] Floating point number represented in scientific notation. n specifies the number of significant figures when the value is expanded. The default value is 10. -f Each of the options and names refers to a function. -F [n] Floating point. n is the number of places after the decimal point when the value is expanded. The default value is 10. -H Hostname mapping. Each name holds a native pathname. Assigning a UNIX format pathname causes it to be converted to a pathname suitable for the current host. This has no effect when the native system is UNIX. -i [base] An integer. base represents the arithmetic base from 2 to 64. The option value can be omitted. The default value is 10. -l Convert uppercase characters to lowercase characters. Unsets the -u option. When used with -i, -E, or -F indicates long vari- ant. -L [n] Left justify. If n is specified, it represents the field width. If the -Z attribute is also specified, then leading zeros are stripped. The option value can be omitted. -n Name reference. The value is the name of a variable that name references. name cannot contain a .. -p Causes the output to be in a format that can be used as input to the shell to recreate the attributes for variables. -r Enables read-only. Once this option is enabled, it cannot be disabled. See readonly(1). -R [n] Right justify. If n is specified it represents the field width. If the -Z option is also specified, zeros are used as the fill character. Otherwise, SPACEs are used. -s Restricts integer size to short when used with -i. -t When used with -f, enables tracing for each of the specified functions. Otherwise, -t is a user defined attribute and has no meaning to the shell. -T tname tname is the name of a type name given to each name. -u Without -f or -i, converts lowercase characters to uppercase and unsets -l. When used with -f, specifies that name is a func- tion that has not yet been loaded. When used with -i specifies that the value is displayed as an unsigned integer. -x Puts each name on the export list. See export(1). name cannot contain a .. -Z [n] Zero fill. If n is specified it represents the field width. The option value can be omitted. The following exit values are returned by typeset in ksh93: 0 Successful completion. >0 An error occurred. If the -v is not specified, whence writes on standard output an absolute pathname, if any, corresponding to name based on the complete search order that the shell uses. If name is not found, no output is produced. If the -v is specified, the output from whence also contains information that indicates how the specified name would be interpreted by the shell in the current execution environment. The following options are supported by the whence built-in command in ksh93: -a Display all uses for each name rather than the first. -f Do not check for functions. -p Do not check to see if name is a reserved word, a built-in, an alias, or a function. -v For each name specified, the shell displays a line that indicates if that name is one of the following: o Reserved word o Alias o Built-in o Undefined function o Function o Tracked alias o Program o Not found The following exit values are returned by whence in ksh93: 0 Successful completion. Each name was found by the shell. 1 One or more names were not found by the shell. >1 An error occurred. On this manual page, ksh93(1) commands that are preceded by one or two + (plus signs) 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. They are not valid function names. 5. Words, following a command preceded by ++ that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), ksh93(1), readonly(1)set(1), sh(1), attributes(5) SunOS 5.11 13 Mar 2008 typeset(1)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy