Sponsored Content
Top Forums Shell Programming and Scripting storing values in a list or array Post 302314262 by KiranKumarKarre on Thursday 7th of May 2009 11:55:54 PM
Old 05-08-2009
storing values in a list or array

i have a file called file.txt having the following entries.
2321
2311
2313
4213

i wnat to store these values in a list and i want to iterate the list using loop and store it in another list
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Storing pointer array in C

All .. I am having a pointer array . And trying to store the addess into that pointer array . please see below the problem i faced code: int cnt1; char *t_array; char *f_array; for(cnt1=0; cnt1<1000; cnt1++) { t_array =... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

2. Shell Programming and Scripting

storing variables in array.Please help

Hi All, I need some help with arrays. I need to take input from the user for hostname, username and password until he enters .(dot) or any other character and store the values in the variable array. I would further connect to the hostname using username and passwd and copy files from server to... (7 Replies)
Discussion started by: nua7
7 Replies

3. Shell Programming and Scripting

fetching values using awk and storing into array

hi all I am using awk utility to parse the file and fetching two different vaues from two different record of a record set. I am able to see the result, now i want to store the result and perform some check of each values form database to mark valid and invalid. could you please help me... (3 Replies)
Discussion started by: singhald
3 Replies

4. Shell Programming and Scripting

Storing blanks in an array in bash

Hi Guys, I have a file which is as follows: 1 2 4 6 7 I am trying to store these values in an array in bash. I have the following script: FILE=try.txt ARRAY=(`awk '{print}' $FILE`) echo ${ARRAY} (3 Replies)
Discussion started by: npatwardhan
3 Replies

5. Shell Programming and Scripting

Storing data in perl 2D array

Respected All, Kindly help me out. I have got file listings in a directory like this: -rw-r--r-- 1 root root 115149 2011-11-17 07:15 file1.stat.log -rw-r--r-- 1 root root 115149 2011-11-18 08:15 file2.stat.log -rw-r--r-- 1 root root 115149 2011-11-19 09:15 file3.stat.log -rw-r--r-- 1... (2 Replies)
Discussion started by: teknokid1
2 Replies

6. Programming

C; storing strings in an array

I am trying to get userinput from stdin and store the lines in an array. If i do this: using a char **list to store strings allocate memory to it #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { char *prog = argv; char **linelist; int... (5 Replies)
Discussion started by: tornow
5 Replies

7. Shell Programming and Scripting

storing multiple values in a array variable

Am using a find command in my script .The output may be one or more. I need to store those values in a array and need to access those. Am unable to find the solution . Any help on this will be helpful. if < code> else a=<find command output which gives the file name either 1 or more> if 1... (1 Reply)
Discussion started by: rogerben
1 Replies

8. Shell Programming and Scripting

Perl next if @array (exclude a list of values)

I'm trying to exlude a list of values with perl to process while reading in a file. Is there a way to use the next if with a list? Example: @array = qw(val1 val2 val3 val6); while (<>) { next if $_ =~ @array; # values I don't want to process here print; # process the rest here }... (8 Replies)
Discussion started by: timj123
8 Replies

9. Shell Programming and Scripting

Storing two dimensional array for postprocessing

Hi Community, Would love to get some quick help on below requirement. I am trying to process mpstat output from multiple blades of my server I would like to assign this the output to an array and then use it for post processing. How can I use a two dimensional array and assign these value ... (23 Replies)
Discussion started by: sshark
23 Replies

10. UNIX for Beginners Questions & Answers

Storing timestamp of files in an array

Hi, I have written the below script to get the timestamp of each files and result is as below Script find /home/user -type f -name "*.json" -printf '%Tc %p\n' | awk {'print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7'} Input -rw-r--r-- 1 user domain users 17382 Jul 19 06:10... (5 Replies)
Discussion started by: nextStep
5 Replies
Arch::SharedIndex(3pm)					User Contributed Perl Documentation				    Arch::SharedIndex(3pm)

NAME
Arch::SharedIndex - a synchronized data structure (map) for IPC SYNOPSIS
use Arch::SharedIndex; my $map = Arch::SharedIndex->new(file => "/tmp/logintimes.idx"); my $time = time; $map->store(migo => $time - 75, bob => $time - 5, enno => $time); printf "All users: %s, %s, %s ", $map->keys; printf "New users: %s ", $map->grep(sub { $_[1] == $time }); printf "Login time of migo: %s ", $map->fetch('migo'); $map->update(sub { $_[1] + 10 }, sub { $_[1] == $time }); $map->store(migo => $time); $map->delete('bob'); printf "Logged users with times: (%s) ", join(", ", $map->hash); DESCRIPTION
Arch::SharedIndex provides a key-value map that can be shared and accessed safely by multiple processes. METHODS
The following methods are available: new, encode_value, decode_value, store_value, fetch_value, delete_value, store, fetch, delete, fetch_store, keys, values, hash, list, grep, filter, update, query_index_list. new options Create a new index object. option is a hash of parameters. file The path of the index file, used to store data. Must not be omitted. can_create Whether the index file is automatically created. Defaults to 1. max_size Maximum number of entries in the index. Defaults to 0 (no limit). expiration Timeout in seconds after which unused entries are removed. Defaults to 0 (don't expire entries) time_renewal Whether fetching values resets the entry expiration timeout. Defaults to 1 if max_size is set, 0 otherwise. perl_data Whether non-scalar perl data can be stored. If true, values are encoded using Data::Dumper. perl_data_indent Indent value for Data::Dumper when perl_data is set. Defaults to 0. perl_data_pair Pair value for Data::Dumper when perl_data is set. Defaults to "=>". encode_value ref Encode the value referenced by ref in a string representation. The encoding is done in place. decode_value ref Decode a value encoded with encode_value from its string representation. The decoding is done in place. store_value key token value Store a value for the given key and token. Create a new token if none is given. Returns the (new) token. Sub-classes should implement this method. fetch_value key token Fetch the value stored for the given key and token. Sub-classes should implement this method. delete_value key token Delete a value stored for the given key and value. Sub-classes should implement this method. store kvp Store a set of key-value pairs. kvp may either be a reference to a hash or array, or list of keys and values. fetch keys Fetch values stored for a list of keys. keys may either be an array reference, or a list of keys. delete keys Delete values stored for a list of keys. keys may either be an array reference, or a list of keys. fetch_store mapfunc keys This is an optimized (fetch or store) in a single step. Fetch values stored for keys, just like fetch, but store values for the missing keys in the process. keys may be an array reference or a list of keys. mapfunc will be called once for every key in keys that has no associated value, with the key as its only argument. Its return value will be stored for that key. keys Returns a list of all valid keys. In scalar context, returns an array reference. Keys are returned in no particular order, but values will return values in matching order if the index has not been changed between calls. values Returns a list of all stored values. In scalar context, returns an array reference. Values are returned in no particular order, but keys will return values in matching order if the index has not been changed between calls. hash Returns the stored keys and values as a perl hash. In scalar context, returns hash reference. list Returns the stored keys and values as a list of pairs (array references with two elements each). In scalar context, returns an array reference. grep predicate Returns a list of keys for which predicate returns a true value. predicate is called once for every key, with the key and the stored value as its first and second argument. filter predicate Deletes every entry for which predicate returns a true value. predicate is called once for every key, with the key and the stored value asi its first and second argument. update mapfunc predicate Updates the value for every key for which predicate returns a true value with the return value from mapfunc. Both predicate and mapfunc are called with the key and the stored values as their first and second argument. update_index_list code Synchronize access and call code with a reference to a list of pairs, each containing the key and token, for every stored value. Used internally by store, fetch, delete, fetch_store, keys, values, hash, list, grep, filter and update. BUGS
Awaiting for your reports. AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). Enno Cramer (uebergeek@web.de--2003/arch-perl--devel). SEE ALSO
For more information, see Arch::SharedCache. perl v5.10.1 2005-09-17 Arch::SharedIndex(3pm)
All times are GMT -4. The time now is 09:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy