Sponsored Content
Full Discussion: iterate over array
Top Forums Shell Programming and Scripting iterate over array Post 302191692 by IMTheNachoMan on Sunday 4th of May 2008 12:04:29 PM
Old 05-04-2008
iterate over array

I can not for the life of me figure out how to iterate over this array

Code:
{
	'name1' =>	{
				'a' =>	[
						'one',
						'two',
					].
				'b' =>	[
						'three',
						'four',
					]
			},
	'name2' =>	{
				'a' =>	[
						'one',
						'two',
					].
				'b' =>	[
						'three',
						'four',
					]
			}
}

I want a for loop to iterate through the first element (name1 and name2 in my example) but I can't figure it out. Help please?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

iterate sed over files

Greetings. I'm having a time of it with this file. I'm trying to do a script that will take two command line inputs, string1 and string2 and use sed to change the text over files in the current directory. This is what I have so far. It appears to work a little, it does create the... (3 Replies)
Discussion started by: rdanda
3 Replies

2. Shell Programming and Scripting

Shell - How to iterate through all the files in a directory?

Hi, I have a directory call Test, which contains files "a", b", "c", etc. I want to go through all of the files inside Test and remove any empty file. How would I do that with shell csh? So far I got... #!/bin/csh if (($#argv == 0) || ($#argv > 1)) then echo "no argument or too... (2 Replies)
Discussion started by: teiji
2 Replies

3. Shell Programming and Scripting

script to iterate

Hi i need to find x in the following equation such that it satisfies this condition: y/x-ln(x)-1.24=0 how can i write a script to iterate to give random x to satisfy this equation. y is different each time too. any help with awk/shell script will be awesome! thanks (1 Reply)
Discussion started by: saint2006
1 Replies

4. Shell Programming and Scripting

Do loop doesn't iterate

I'm trying to send the file list as parameter to another job and execute it. But the loop doesn't work, the inner job is running only once and not twice as expected for filelist in $(ls -rt *.txt | tail -2) do echo $filelist export filelist cmd="$Program -config $configfile -autoexec... (11 Replies)
Discussion started by: asandy1234
11 Replies

5. Shell Programming and Scripting

Iterate array using loop over ssh

A simple script: #!/bin/bash test=test test1=(test1 test2 test3) echo ${test1 } ssh server 'echo '$test'; echo '${test1 }' ; echo '${test1}' ; for m in $(seq 1 $(echo '${test1 }' | tr " " "\n" | wc -l)); do echo $m ; echo '${test1}'; done'Here is the result: test1 test2 test3 testing... (5 Replies)
Discussion started by: mharald
5 Replies

6. Shell Programming and Scripting

Awk: Iterate over all records, stop when value < threshold

Hello I have data arranged in two columns 0 7.7272086460791485 1 7.560656885151559 2 7.019966124180658 3 7.2403229620576015 4 7.200882072174212 5 7.3231008505909445 6 7.284184600697482 7 6.933936488650265 8 7.311824413328238 9 7.651279125577341 10 7.536873675349084 11... (19 Replies)
Discussion started by: chrisjorg
19 Replies

7. Shell Programming and Scripting

Using nested for loop to iterate over file names

I'm trying to grab a list of file names from a directory, then process those files 5 at a time. In the link below. Instead of using files I'm using the files array which contains 15 strings starting with AAA. So I'm trying to assign $fileset 5 of the strings at a time to pass to a command. So... (4 Replies)
Discussion started by: zBernie
4 Replies

8. Shell Programming and Scripting

Iterate column with perl

I can not figure out how to iterate a perl command that inputs a value into columns and then combines them. I need to put a numerical value in column one and the word "Null" in all others, and then join at the end. I think the below is close, but I am not sure about the lines in bold. I... (7 Replies)
Discussion started by: cmccabe
7 Replies

9. UNIX for Beginners Questions & Answers

Script to iterate over several options

Have two 3 files which has list of servers,users and location and base url which is common on every server A = server1 server2 server3 B = user1 user2 user3 C = dom1 dom2 dom3 baseurl=/opt/SP/ and what i have to achieve is below via ssh from REMOTE SERVER for it's first iteration it... (7 Replies)
Discussion started by: abhaydas
7 Replies

10. Shell Programming and Scripting

Iterate over `dirs` in a bash script

I would like to iterate over `dirs`in a script, but the script will never show more than one (current) folder #! /bin/bash for i in `dirs` do echo ${i} done echo ++++++++++++++++++ for i in $( dirs -p ) do echo ${i} done echo ------------------ dirscontent=`dirs` echo... (5 Replies)
Discussion started by: alexanderb
5 Replies
LINK(2) 							System Calls Manual							   LINK(2)

NAME
link - make a hard link to a file SYNOPSIS
link(name1, name2) char *name1, *name2; DESCRIPTION
A hard link to name1 is created; the link has the name name2. Name1 must exist. With hard links, both name1 and name2 must be in the same file system. Unless the caller is the super-user, name1 must not be a directory. Both the old and the new link share equal access and rights to the underlying object. RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
Link will fail and no link will be created if one or more of the following are true: [ENOTDIR] A component of either path prefix is not a directory. [EINVAL] Either pathname contains a character with the high-order bit set. [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or entire length of either path name exceeded 1023 characters. [ENOENT] A component of either path prefix does not exist. [EACCES] A component of either path prefix denies search permission. [EACCES] The requested link requires writing in a directory with a mode that denies write permission. [ELOOP] Too many symbolic links were encountered in translating one of the pathnames. [ENOENT] The file named by name1 does not exist. [EEXIST] The link named by name2 does exist. [EPERM] The file named by name1 is a directory and the effective user ID is not super-user. [EXDEV] The link named by name2 and the file named by name1 are on different file systems. [ENOSPC] The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory. [EDQUOT] The directory in which the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. [EIO] An I/O error occurred while reading from or writing to the file system to make the directory entry. [EROFS] The requested link requires writing in a directory on a read-only file system. [EFAULT] One of the pathnames specified is outside the process's allocated address space. SEE ALSO
symlink(2), unlink(2) 4th Berkeley Distribution August 26, 1985 LINK(2)
All times are GMT -4. The time now is 12:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy