Sponsored Content
Full Discussion: multidimensional arrays
Top Forums Shell Programming and Scripting multidimensional arrays Post 302126843 by radoulov on Friday 13th of July 2007 11:39:19 AM
Old 07-13-2007
Is awk available?

Code:
$ cat infile
name1
data1
name2
data2
name3
data3
$ print ${.sh.version}
Version M-12/28/93d
$ awk '{x[$1]=$2}END{for(i in x)print "index:",i,"element:",x[i]}' <(paste -d" " - -<infile)
index: name1 element: data1
index: name2 element: data2
index: name3 element: data3

For ksh88 use paste -d" " - -<infile|awk ...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multidimensional array in perl

i'm trying to open a file with three or more columns and an undetermined, but finite number of rows. I want to define an array for each row with each element of the row as a sub array. The columns are separated by tabs or spaces. Here's the file: 12x3.12z34b.342sd3.sds 454.23.23.232 ... (9 Replies)
Discussion started by: prkfriryce
9 Replies

2. Programming

multidimensional array using c++ vector

Hi! I need to make dynamic multidimensional arrays using the vector class. I found in this page How to dynamically create a two dimensional array? - Microsoft: Visual C++ FAQ - Tek-Tips the way to do it in 2D, and now i'm trying to expand it to 3D but i don't understand how is the operator working,... (0 Replies)
Discussion started by: carl.alv
0 Replies

3. Shell Programming and Scripting

multidimensional arrays using awk

i'm trying to use awk to count a listing similar to the following and get a report of the listing similar to the one below it. y,pizza n,pizza y,pizza y,pizza n,tomato n,tomato y,cheese y,cheese n,cheese report ---- pizza,3,1 tomato,0,2 cheese,2,1 (1 Reply)
Discussion started by: multimulti
1 Replies

4. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

5. Shell Programming and Scripting

multidimensional array in awk

Hi, I was trying to process a file with the help of awk. I want to first display all the rows that contains 01 and at the end of processing I have to print some portion of all the lines. like below. Output expected: (2 Replies)
Discussion started by: ahmedwaseem2000
2 Replies

6. Programming

Multidimensional arrays and sort.

My language is C++. I have a multidimensional vector that I would like to sort by a specific "cell" or "field" within the main vector. Does anyone have any information on how to do this? I have searched all over the internet and every reference manual I can find. So far I have found very little to... (2 Replies)
Discussion started by: sepoto
2 Replies

7. Programming

question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies

8. Shell Programming and Scripting

Multidimensional arrays

Hi Experts, I'm a newbie.....multidimensional arrays in shell scripts is possible??? If so, can anyone guide me with an example.....and also can anyone tell me, how we can create a table like ouput format in shell script....the output should look like this one: 1 2 3 4 5 6 6 5 4 3... (4 Replies)
Discussion started by: kritibalu
4 Replies

9. Shell Programming and Scripting

Multidimensional arrays Shell Programming and Scripting

I have two files: file-1 is a list of number of interfaces in the switch and file-2 have VLAN-ID , VLAN-NAME , Interface belong to that VLAN like this: file-1: 1/1 1/2 1/3 1/4 1/5 . . file-2: 1,"vlan-wifi",1/1,1/7,1/8 (9 Replies)
Discussion started by: SULTAN01
9 Replies

10. Shell Programming and Scripting

Multidimensional array

I am learning about bash system variables, such as $ , @ and #. I have this piece of script implementing an array and it is doing its job just fine. This is not the only array I will be using. Just for ease of maintenance and more coding I would like to have the arrays in two dimensional... (4 Replies)
Discussion started by: annacreek
4 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 07:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy