Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Confuse on how to use array and eval.. Post 62085 by Perderabo on Friday 11th of February 2005 08:38:20 AM
Old 02-11-2005
Code:
bash-2.05b$
bash-2.05b$ declare -a xyz[50]
bash-2.05b$ xyz[4]="y"
bash-2.05b$ xyz[7]="n"
bash-2.05b$ echo ${xyz[4]}
y
bash-2.05b$ k=7
bash-2.05b$ echo ${xyz[k]}
n
bash-2.05b$ xyz[k]=q
bash-2.05b$ echo ${xyz[k]}
q
bash-2.05b$ xyz[22]="na"
bash-2.05b$ echo ${xyz[*]}
y q na
bash-2.05b$

eval is not "a link to array" whatver that means. You don't need that declare, You can just start using the array and it will pop into existence. You can add the [50] to the declare for documentation reasons, but bash ignores it and will grow the array as required.
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Solaris Linux Windows partition confuse

Dear All I tried to follow the instruction in this link: http://multiboot.solaris-x86.org/v/2.html I created all these partitions as mentioned in the link above by using partition commander 9 Fist stage: I installed XP in first partition (hda1)....success. Second stage: Install... (0 Replies)
Discussion started by: zillah
0 Replies

2. Shell Programming and Scripting

how to get status array for the commands in eval

I want to get a status code array for the commands in eval. For example, eval "ls abc; ls def; ls $HOME" I want to get the status code for each ls command in eval. Is there any way to make it? Thanks. (2 Replies)
Discussion started by: pankai
2 Replies

3. Shell Programming and Scripting

eval, array, number of elements - couldn't get it

I try to get a number of elements in an array, using dynamic array name. I need the array name to be dynamic. The array name is constructed as 'inf_ln_$nmb', where $nmb is a file line number So, say I have the arr 'inf_ln_4': > for (( el=0; el<${#inf_ln_4}; el++ )); do > echo "$el:... (1 Reply)
Discussion started by: alex_5161
1 Replies

4. Shell Programming and Scripting

EVal

Hi All, I'm running some encrypted data through a script I wrote. In order to do this, I'm using eval to resolve some of my variables. At the moment, when I use eval to resolve, it strips out some of my encrypted values, and totally drops some others. For example if I have the value ab1"3 it drops... (1 Reply)
Discussion started by: Khoomfire
1 Replies

5. Shell Programming and Scripting

Using eval to populate an array in the background

Hi. I am trying to populate an array using eval in the background within a function. So this function will create a list of 3 character directories from SVN and store in an array. I want to call this function when the script starts in the background unknown to the user. The problem is that... (2 Replies)
Discussion started by: jmiaebrown
2 Replies

6. Shell Programming and Scripting

Strange result of eval, how does eval really work with ssh?

Hi all, some small script with eval turned me to crazy. my OS is linux Linux s10-1310 2.6.16.53-0.8.PTF.434477.3.TDC.0-smp #1 SMP Fri Aug 31 06:07:27 PDT 2007 x86_64 x86_64 x86_64 GNU/Linux below script works well #!/bin/bash eval ssh remotehost date eval ssh remotehost ls below... (1 Reply)
Discussion started by: summer_cherry
1 Replies

7. HP-UX

Confuse to run scsimgr

Hello folk, I'm trying to study HP-UX by myself. Now I'm reading some stuffs about how to get information about lunpath, lun and etc.. My problem is when I execute scsimgr like this: # scsimgr get_info -H 0/1/2/0.149.0.255.10.11.0 old new if Usage: scsimgr -o old_target_name -n... (1 Reply)
Discussion started by: alfastar
1 Replies

8. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (1 Reply)
Discussion started by: vivek d r
1 Replies

9. Shell Programming and Scripting

Error in eval eval command to print html tags

anyone has any info on why this is complaining??? vivek@vivek-c5e55ef2e ~/TAC $ zoneCounter=1 vivek@vivek-c5e55ef2e ~/TAC $ optUsage1=23% vivek@vivek-c5e55ef2e ~/TAC $ eval eval echo "<th>Zone $zoneCounter </th><th align=\"left\"> \$optUsage$zoneCounter </th>" -bash: syntax error... (13 Replies)
Discussion started by: vivek d r
13 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 08:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy