Sponsored Content
Top Forums Shell Programming and Scripting Store value in array with awk Post 302726445 by RudiC on Sunday 4th of November 2012 10:34:10 AM
Old 11-04-2012
If you are talking shell array, try this. Syntax will vary from shell to shell, this one is bash (index starting at 0):
Code:
$ X=($(awk '{print $1}' file))
$ echo ${#X[@]}                            # element count
13
$ echo ${X[@]}                             # all elements
32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794
$ Y=($(awk '{print $2}' file))
$ echo ${X[2]}, ${Y[2]}                    # third pair
32784, 01

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to store the values in a file into an array

Hi, I do have a file and the contents are as follws: 10 20 30 40 50 Now I want to store those values into an array. How can be done this ?? (3 Replies)
Discussion started by: risshanth
3 Replies

2. Shell Programming and Scripting

Store values in an Array

Hi all. Well, I have the next code: I need to make an array with the values I have in the bucle, but just don't get it... Question is, how can I store in an array that values, and how can I display them with echo? (8 Replies)
Discussion started by: crcbad
8 Replies

3. UNIX for Dummies Questions & Answers

trying to store variables in an array

im looping through an array setting three variables each time (one of the variables gives me the position in the array and is incremented each loop) im trying to then set the variables to that position in the array without much luck. any ideas? anArray=`$VAR1+$VAR2+"("$pos")"` (1 Reply)
Discussion started by: magnia
1 Replies

4. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

5. Shell Programming and Scripting

Assign zero to strings that don't appear in block, store result in AWK array

Hi to all, I have this input: <group> <x "2">Group D</x> <x "3">Group B</x> <x "1">Group A</x> </group> <group> <x "1">Group E</x> <x "0">Group B</x> <x "1">Group C</x> </group> <group> ... (11 Replies)
Discussion started by: Ophiuchus
11 Replies

6. Shell Programming and Scripting

How to store output of command to an array

Hello Guys, I am trying to store output of command to an array and then want to print, but it showing an error that "bad substitution". I am not getting why it's happening. Can anyone help me? #!/usr/bin/sh hr=0 min=0 i=1 last $1 | grep -w `date "+%b"` | grep -v '\(0:.*\)' | grep -vw sshd... (8 Replies)
Discussion started by: kasparov
8 Replies

7. Shell Programming and Scripting

Store the output values in array

Hi, How to store the values in array from output result, EG: I have the result like this, ps, google, 1.txt, 1 sam, google, 2.txt, 2 These are the four values followed by comma in two sets. I need to store these values set by set. One set contains four values followed by comma. ... (2 Replies)
Discussion started by: KarthikPS
2 Replies

8. Shell Programming and Scripting

Can -v option in awk be used to store an array of variables?

I want to pass an array of variables to be inserted by awk in the 2nd column of a file. Empl No. Employee Age 1000000 22 1100000 24 1200000 26 Now, I want to pass an array having three different ages which need to replace the... (7 Replies)
Discussion started by: Nishi_Licious
7 Replies

9. Shell Programming and Scripting

ksh : need to store the output of a awk command to a array

I have awk command : awk -F ' ' '{ print $NF }' log filename And it gives the output as below: 06:00:00 parameters: SDS (2) no no no no doc=4000000000). information: (6 Replies)
Discussion started by: ramprabhum
6 Replies

10. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies
Apache::Session::Store::LDAP(3pm)			User Contributed Perl Documentation			 Apache::Session::Store::LDAP(3pm)

NAME
Apache::Session::Store::LDAP - Use LDAP to store persistent objects SYNOPSIS
use Apache::Session::Store::LDAP; my $store = new Apache::Session::Store::LDAP; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); DESCRIPTION
This module fulfills the storage interface of Apache::Session. The serialized objects are stored in an LDAP directory file using the Net::LDAP Perl module. OPTIONS
This module requires one argument in the usual Apache::Session style. The keys ldapServer, ldapBase, ldapBindDN, ldapBindPassword are required. The key ldapPort is optional. Example: tie %s, 'Apache::Session::LDAP', undef, { ldapServer => 'localhost', ldapBase => 'dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', }; AUTHOR
Xavier Guimard, <guimard@> COPYRIGHT AND LICENSE
Copyright (C) 2009, 2012 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. SEE ALSO
Apache::Session perl v5.14.2 2012-06-26 Apache::Session::Store::LDAP(3pm)
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy