Sponsored Content
Top Forums Shell Programming and Scripting Accessing single elements of a awk array in END Post 302207740 by robotronic on Friday 20th of June 2008 04:28:56 PM
Old 06-20-2008
Without quotes, "vec-7" is evaluated as "value of variable vec" minus "7", which isn't a good key for your hash.

Try this:
Code:
print tst["vec-7"]

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Could someone give me an example of awk accessing array defined in Korn Shell?

As per title and much apprecieated! (2 Replies)
Discussion started by: biglau
2 Replies

2. Shell Programming and Scripting

Accessing awk array from shell

Hi, i want awk to read a file and place it's content into two arrays. When trying to read these arrays with a "for a in ${source_path} "-Loop it gives the right result. But when trying to access directly (/bin/echo ${source_path}) it doesn't work. I read "all "the awk threads in this forum and... (6 Replies)
Discussion started by: bateman23
6 Replies

3. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

4. Shell Programming and Scripting

Accessing array elements

Hi, My doubt is how to access array elements.. Situation is as below: #!/bin/ksh set -x typeset -i x=0 typeset -i y=0 typeset -i BID=0 typeset -i count=0 while ] ; do x=`expr $x + 1`; hwmgr show scsi > scsi.tmp while read line; do set... (1 Reply)
Discussion started by: mansa
1 Replies

5. Shell Programming and Scripting

awk - array elements as condition

Hi, can I use array elements ( all ) in conditional statements? the problem is ,the total number of elements is not known. e.g A is an array with elements - 1,2,3 now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this if ( $1 ~... (1 Reply)
Discussion started by: shellwell
1 Replies

6. Shell Programming and Scripting

AWK help: how to compare array elements against a variable

i have an array call ignore. it is set up ignore=34th56 ignore=re45ty ignore=rt45yu . . ignore=rthg34 n is a variable. I have another variable that i read from a different file. It is $2 and it is working the way i expect. array ignore read and print correct values. in the below if... (2 Replies)
Discussion started by: usustarr
2 Replies

7. Shell Programming and Scripting

printing array elements inside AWK

i just want to dump my array and see if it contains the values i am expecting. It should print as follows, ignore=345fht ignore=rthfg56 . . . ignore=49568g Here is the code. Is this even possible to do? please help termReport.pl < $4 | dos2ux | head -2000 | awk ' BEGIN... (0 Replies)
Discussion started by: usustarr
0 Replies

8. Shell Programming and Scripting

Match elements in an AWK multi-dimensional array

Hello, I have two files in the following format; file1: A B C D E F G H I J K L file2: 1 2 3 4 5 6 7 8 9 10 11 12 I have read them both in to multi-dimensional arrays. I need a file that has column 2 of the first file printed out for each column 3 of the second file ie... ... (3 Replies)
Discussion started by: cold_Que
3 Replies

9. Shell Programming and Scripting

Problem accessing array elements

Hi all, I can’t resolve an array element access issue on (Linux/pdksh) .. So I’m positing for advice.By the way - a friend demonstrated to me - same script works as expected under Solaris. I have been working on a documentation project where many *.jpg screen shots are used in the... (4 Replies)
Discussion started by: njdpo
4 Replies

10. Shell Programming and Scripting

Awk: Append new elements to an array

Hi all, I'm dealing with a bash script to merge the elements of a set of files and counting how many times each element is present. The last field is the file name. Sample files: head -5 *.tab==> 3J373_P15Ac1y2_01_LS.tab <== chr1 1956362 1956362 G A hom ... (7 Replies)
Discussion started by: lsantome
7 Replies
sendfilev(3EXT) 					    Extended Library Functions						   sendfilev(3EXT)

NAME
sendfilev - send a file SYNOPSIS
cc [ flag... ] file... -lsendfile [ library... ] #include <sys/sendfile.h> ssize_t sendfilev(int fildes, const struct sendfilevec *vec, int sfvcnt, size_t *xferred); DESCRIPTION
The sendfilev() function attempts to write data from the sfvcnt buffers specified by the members of vec array: vec[0], vec[1], ... , vec[sfvcnt-1]. fildes is a file descriptor to a regular file or to a AF_NCA, AF_INET, or AF_INET6 family type SOCK_STREAM socket that is open for writing. This function is analogous to the writev() system call. See writev(2). However, instead of sending out chunks of data, sendfilev() can read input data from data buffers or file descriptors. The following is the sendfilevec structure: typedef struct sendfilevec { int sfv_fd; /* input fd */ uint_t sfv_flag; /* Flags. see below */ off_t sfv_off; /* offset to start reading from */ size_t sfv_len; /* amount of data */ } sendfilevec_t; #define SFV_FD_SELF (-2) To send a file, open the file for reading. Point sfv_fd to the file descriptor returned as a result. See open(2). sfv_off should contain the offset within the file. sfv_len should have the length of the file to be transferred. The xferred parameter is updated to record the total number of bytes written to out_fd. The sfv_flag field is reserved and should be set to zero. To send data directly from the address space of the process, set sfv_fd to SFV_FD_SELF. sfv_off should point to the data, with sfv_len con- taining the length of the buffer. PARAMETERS
The sendfilev() function supports the following parameters: fildes A file descriptor to a regular file or to a AF_NCA, AF_INET, or AF_INET6 family type SOCK_STREAM socket that is open for writing. For AF_NCA, the protocol type should be zero. vec An array of SENDFILEVEC_T, as defined in the sendfilevec structure above. sfvcnt The number of members in vec. xferred The total number of bytes written to out_fd. RETURN VALUES
Upon successful completion, sendfilev() returns total number of bytes written to out_fd. Otherwise, it returns -1, and errno is set to indicate an error. xferred contains the amount of data successfuly transferred, which can be used to discover the error vector. ERRORS
EAFNOSUPPORT The implementation does not support the specified address family for socket. EPROTOTYPE The socket type is not supported. EBADF The fildes argument is not a valid descriptor open for writing or an sfv_fd is invalid or not open for reading. EACCES The process does not have appropriate privileges or one of the files pointed by sfv_fd does not have appropriate permissions. EPIPE The fildes argument is a socket that has been shut down for writing. EIO An I/O error occurred while accessing the file system. EFAULT The vec argument points to an illegal address. EFAULT The xferred argument points to an illegal address. EINVAL The sfvcnt argument was less than or equal to 0. One of the sfv_len in vec array was less than or equal to 0, or greater than the file size. An sfv_fd is not seekable. EAGAIN Mandatory file or record locking is set on either the file descriptor or output file descriptor if it points at regular files. O_NDELAY or O_NONBLOCK is set, and there is a blocking record lock. An attempt has been made to write to a stream that cannot accept data with the O_NDELAY or the O_NONBLOCK flag set. USAGE
The sendfilev() function has a transitional interface for 64-bit file offsets. See lf64(5). EXAMPLES
The following example sends 2 vectors, one of HEADER data and a file of length 100 over sockfd. sockfd is in a connected state, that is, socket(), accept(), and bind() operation are complete. #include <sys/sendfile.h> . . . int main (int argc, char *argv[]){ int sockfd; ssize_t ret; size_t xfer; struct sendfilevec vec[2]; . . . vec[0].sfv_fd = SFV_FD_SELF; vec[0].sfv_flag = 0; vec[0].sfv_off = "HEADER_DATA"; vec[0].sfv_len = strlen("HEADER_DATA"); vec[1].sfv_fd = open("input_file",.... ); vec[1].sfv_flag = 0; vec[1].sfv_off = 0; vec[1].sfv_len = 100; ret = sendfilev(sockfd, vec, 2, &xfer); . . . } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
open(2), writev(2), libsendfile(3LIB), sendfile(3EXT), socket(3SOCKET), attributes(5) SunOS 5.10 19 Apr 2004 sendfilev(3EXT)
All times are GMT -4. The time now is 10:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy